PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, I'm trying to use preg_match_all to match a set of values and store them as an array that I can loop through using foreach. I've tried to do it like this:
$pattern = '/<span class="Normal-C0?">.+?<\/span>/';
preg_match_all($pattern,$table,$match);
foreach($match as $entry){echo $entry}
Using print_r $match outputs the right values in what looks to me like an array so the pattern matching is fine. Also I know the foreach loop is OK because if substituting an arbitrary array for $match outputs correctly. The code as above however just outputs the word 'Array'. Can anyone help? Thanks
The if(is_array) line checks to see if the value contained in $value is an array and if it is it treats it as such with the foreach loop, which prints out the contents of the array.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering