maxudaskin Posted April 2, 2008 Share Posted April 2, 2008 Any Idea why the following code brings up Warning: array_values() [function.array-values]: The argument should be an array in /home/.grable/vzoom/virtualzoom.net/comm/forum.php on line 566 We Cannot Find This Specified Image Input [img=http://www.virtualzoom.net/screenshots/jan-screen-lg.jpg] <?php $text = $posts['text']; $message = preg_replace($find,$rplc,$text); preg_match_all('/\[img\](.+?)\[\/img\]/', $text, $url); $imagekeys = array_keys($url[1]); for($i=0;$i<count($imagekeys);$i++){ $imagevals = array_values($url[$i][0]);// Line 566 echo "<img src\"" . $imagevals[$i] . "\" height=\"" . $height . "\" width=\"" . $width . "\" alt=\"We Cannot Find This Specified Image\" /><br />"; } $message = str_replace($smilies,$locations,$message); echo nl2br($message); ?> Link to comment https://forums.phpfreaks.com/topic/99102-for-each/ Share on other sites More sharing options...
uniflare Posted April 2, 2008 Share Posted April 2, 2008 try print_r($url[$i][0]); just before the error line. Link to comment https://forums.phpfreaks.com/topic/99102-for-each/#findComment-507118 Share on other sites More sharing options...
maxudaskin Posted April 2, 2008 Author Share Posted April 2, 2008 Ok, the key count is 1, but it does not echo the image or print the result... <?php $text = $posts['text']; $message = preg_replace($find,$rplc,$text); preg_match_all('/\[img\](.+?)\[\/img\]/', $text, $url); $imagekeys = array_keys($url[1]); for($i=0;$i<count($imagekeys);$i++){ print_r($url[$i][0]); echo "<img src\"" . $imagevals[$i] . "\" height=\"" . $height . "\" width=\"" . $width . "\" alt=\"We Cannot Find This Specified Image\" /><br />"; } $message = str_replace($smilies,$locations,$message); echo nl2br($message); ?> Link to comment https://forums.phpfreaks.com/topic/99102-for-each/#findComment-507122 Share on other sites More sharing options...
uniflare Posted April 2, 2008 Share Posted April 2, 2008 what do you mean by "doesnt print"? What doesnt print? the html link? if so, then the count is most likely 0 :/. the reason i said to use print_r() is it shows you a nice digram of array variables, you can use print_r() to debug variables and strings etc. its very useful, i suggest using print_r on $url and checking the variables to make sure your using them ok. also give us what print_r($url); is from the html source Link to comment https://forums.phpfreaks.com/topic/99102-for-each/#findComment-507248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.