I need help reordering this data in the var $favsget $favsget = '123,456,768,55,66,55,'; $favlist = explode(",",$favsget); foreach ( $favlist as $name){ //Now I need to reverse the order and it needs to be exactly from last to first where last = 55 and first is 123 then do other stuff after I get it reordered Can anyone give me some insight how to do this? Thanks in advance!
you can try this $favsget = '123,456,768,55,66,55'; $favlist = explode(',', $favsget); $newArray = array(); $len = count($favlist) - 1; for($i = $len; $i >= 0; $i--) { $newArray[] = $favlist[$i]; } PHP:
$favsget = '123,456,768,55,66,55,'; $favlist = explode(",",$favsget); $total = count($favlist) - 1; foreach ($favlist as $key => $value) { $favlist_reversed[$total] = $favlist[$key]; $total--; } PHP: