yanivkalfa Posted January 28, 2008 Share Posted January 28, 2008 well i have an 2d array $arra[][] i dont know its size couse i get this array from preg_match_all i want to make a loop that prints the array some way . i thinks there is a way of doing s with foreach but dont know how . using print_r is not an option couse the resualts of this array are gonna be links or urls for Pics its sould be something like that : <?php $subject = $arr["PicLinks"]; $pattern = '/(http:\/\/[\S]*)/i'; preg_match_all($pattern, $subject, $arra, $PREG_SET_ORDER); echo '<P><img src="'.$arra[0][0].'" width="421" height="212" />';// this is how its sould be aventualy (only with a loop instead of this actual acho ?> i have been trying to do : foreach($arra as $val) { foreach($val as $arraa) { echo '<img src="'.$arraa.'" />'; } } didnt work as i planned. anyways 1 more thing how do i do <P> but not complitly p just to go down 1 raw like \n in echo i mean i want to have list like this aasasasa sasasasa sasasas and not like this : sasasasa sasasasa sasasasa sasasas how do i achive this Quote Link to comment https://forums.phpfreaks.com/topic/88151-how-to-print-a-2d-array-not-know-its-size/ Share on other sites More sharing options...
laffin Posted January 28, 2008 Share Posted January 28, 2008 recursive functions array_string_display($array) { foreach($array as $item) { if(is_array($item)) array_string_display($array); else if(is_string($item)) echo "Oh I got one: $item<BR>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/88151-how-to-print-a-2d-array-not-know-its-size/#findComment-451029 Share on other sites More sharing options...
yanivkalfa Posted January 29, 2008 Author Share Posted January 29, 2008 thanks Quote Link to comment https://forums.phpfreaks.com/topic/88151-how-to-print-a-2d-array-not-know-its-size/#findComment-451873 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.