ok so im new with the whole foreach thing, i use to just do a bunch of different lines (Taught myself to code) so if you could help me with this one foreach ($result[$key]['pic_big'] as $key => $value) { if ($result[$key]['oauth_provider'] != '4dare') { if (strlen($value) > 6){ $string = substr($value, 0, 6); } if ($string == "users/") { $pic[$key] = "http://www.trollfight.com/".$result[$key]['pic_big'].""; }else{ $pic[$key] = $result[$key]['pic_big']; } }else{ $pic[$key] = $result[$key]['pic_big']; } } Code (markup): Basically my mysql class returns values as $result3[lineno.][column] eg $result[1]['name'] and i need to test each line to see where to load the avatar from, eg either trollfight or local Thanks in advance alex
You didn't mention what problems you have. but try this code foreach ($result as $key => $value) { if ($result[$key]['oauth_provider'] != '4dare') { if (strlen($value['pic_big']) > 6){ $string = substr($value['pic_big'], 0, 6); } if ($string == "users/") { $pic[$key] = "http://www.trollfight.com/".$result[$key]['pic_big'].""; }else{ $pic[$key] = $result[$key]['pic_big']; } }else{ $pic[$key] = $result[$key]['pic_big']; } } PHP:
foreach($result3 as $i => $v) { if ($result3[$i]['oauth_provider'] != '4dare') { if (strlen($result3[$i]['pic_big']) > 6){ $string = substr($result3[$i]['pic_big'], 0, 6); } $picno = 'pic'.$i.''; if ($string == "users/") { $pic[$i] = "http://www.trollfight.com/".$result3[$i]['pic_big'].""; }else{ $pic[$i] = $result3[$i]['pic_big']; } }else{ $pic[$i] = $result3[$i]['pic_big']; } } Code (markup): I did it like 2 seconds before your reply mate! Cheers Works perfectly!