我需要在 value="" 的引号之间找到字符/字母,然后更改它。
我知道它可以学习如何使用正则表达式等查找“未知数据”。
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$fullstring = "this is my [tag]dog[/tag]";
$parsed = get_string_between($fullstring, "[tag]", "[/tag]");
echo $parsed; // (result = dog)
$newstring = str_replace($parsed,"new phrase or whatever",$fullstring);
echo $newstring; // (result = this is my [tag]new phrase or whatever[/tag])