I have this script which reads data from another website but i want the script to grab the data from bottom up rather then top down.
For example if the results are:
Result #1 Result #2 Result #3
I want to get #3 first, then 2 then 1. At the moment it gets 1 then 2 then 3.
Here is my script currently
$pattern = '#<a href="(.*?)" class="normalgrey font12px plain bold">(.*?)</a>#';
preg_match_all($pattern,$fileList,$match);
Thanks in advance!
What you need is the array_reverse() function on the $match results array :
http://www.php.net/manual/en/function.array-reverse.php
$reversed = array_reverse($match);
print_r($reversed);
$match = array_reverse($match);
Sometimes the array does not allow for this (thanks to Calimero's comment) which happens when you supply flags to preg_match_* such as PREG_PATTERN_ORDER to alter the structure of the $match array. If that is the case then use
$match[0] = array_reverse($match[0]);
That second one is for anyone reading this in the future that can't get it to work.