Replace substrings with an incremented counter value

后端 未结 5 1882
耶瑟儿~
耶瑟儿~ 2021-01-17 08:25

Basically what I\'m looking for is the PHP version of this thread: Find, replace, and increment at each occurence of string

I would like to replace the keyword follow

5条回答
  •  旧巷少年郎
    2021-01-17 09:29

    If I understood your question properly...

    $fV) $new[] = (substr($fV, 0, 1)==">")? str_replace("num", $fK/2, $fV) : $fV;
    //optionally print it out in the browser.
    echo "
    ";
    print_r($new);
    echo "
    "; //optionally write to file... $output = fopen("output.txt", 'w'); foreach($new as $n) fwrite($output, $n); fclose($output);

提交回复
热议问题