I need to extract some HTML / PHP content and put it into an array.
Here is what I have
The code below is within a string called $string for example.
<html>
<?php myclass->my_function('First', 'Last'); ?>
<p>Some other content</p>
<?php myclass->my_function(1, 2, 3); ?>
</html>
I want to find all the values from the functions and sum them into an array with preg_match. Only myclass->my_function function values should be found.
The array should look like this
$array = array(
1 => array('First', 'Last'),
2 => array(1,2,3),
);
Then I want preg_replace to replace all the rows with [explode_id] and the result should be:
<html>
[explode_1]
<p>Some other content</p>
[explode_2]
</html>
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…