How to shift the result of regular php replacement?
$str='';$a=preg_replace('/\_data=[\"|\']([a-zA-Z0-9\_]+)([\s\"\']*)/eis', "data_array('\\1')", $str);die($a);function data_array($key){$code=add_p("$key");return "$code";}function add_p($v){ $value=""; return "$value";}
// Obtain the result
**************************************** **************************************** ***************************
>
>
>
**************************************** **************************************** ***************************
Expected results
**************************************** **************************************** ***************************
**************************************** **************************************** ***************************
**************************************** **************************************** ***************************
**************************************** **************************************** ***************************
Reply to discussion (solution)
There is no difference between the two results!
$a=preg_replace('/\s+\_data=[\"|\']([a-zA-Z0-9\_]+)([\s\"\']*)>/eis', "data_array('\\1')", $str);die($a); function data_array($key){ $code=add_p($key); return $code; } function add_p($v){ $value=">"; return $value; }
$a=preg_replace('/\s+\_data=[\"|\']([a-zA-Z0-9\_]+)([\s\"\']*)>/eis', "data_array('\\1')", $str);die($a); function data_array($key){ $code=add_p($key); return $code; } function add_p($v){ $value=">"; return $value; }
Ask: How can I change the html format?
$ Str ='
';
Expected results
**************************************** **************************************** ***************************
**************************************** **************************************** ***************************
$str='';$a=preg_replace_callback('/<(\w+)\s+\_data=[\"|\']([a-zA-Z0-9\_]+)([\s\"\']*)\s*class="(.+?)"><\/\1>/is', "data_array", $str);die($a); function data_array($key){ $code=add_p($key[4], $key[2]); return $code; } function add_p($class, $id){ $value=""; return $value; }