phpretard Posted January 26, 2008 Share Posted January 26, 2008 Can PHP turn this into one foreach statement? foreach($link as $value){echo $value;} foreach($link1 as $value1){echo $value1;} Quote Link to comment https://forums.phpfreaks.com/topic/87964-solved-2-from-me-1-from-you/ Share on other sites More sharing options...
laffin Posted January 26, 2008 Share Posted January 26, 2008 how about $narray=array_merge($array1,$array2); foreach($narray as $item) echo $item; Quote Link to comment https://forums.phpfreaks.com/topic/87964-solved-2-from-me-1-from-you/#findComment-450060 Share on other sites More sharing options...
phpretard Posted January 26, 2008 Author Share Posted January 26, 2008 I (once again) wasn't as clear with my question but your answer was dead on. I need one array's value as the url and the other as the link name. while() { foreach($link as $value); foreach($link_name as $value1); echo "<a href=$value>$value1</a>"; } btw - Thank you for your quick response. Quote Link to comment https://forums.phpfreaks.com/topic/87964-solved-2-from-me-1-from-you/#findComment-450068 Share on other sites More sharing options...
phpretard Posted January 26, 2008 Author Share Posted January 26, 2008 Do you need more code? Quote Link to comment https://forums.phpfreaks.com/topic/87964-solved-2-from-me-1-from-you/#findComment-450081 Share on other sites More sharing options...
laffin Posted January 26, 2008 Share Posted January 26, 2008 ahhh than use array_combine $narray=array_combine($array1,$array2); foreach($narray as $key => $item) echo "<a href=\"$key\">$item</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/87964-solved-2-from-me-1-from-you/#findComment-450085 Share on other sites More sharing options...
phpretard Posted January 26, 2008 Author Share Posted January 26, 2008 What does this mean? Fatal error: Call to undefined function: array_combine() $url=unserialize($row['url']); $name=unserialize($row['name']); $link=$url; $link_name=$name; $narray=array_combine($link,$link_name); foreach($narray as $key => $item) echo "<a href=\"$key\">$item</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/87964-solved-2-from-me-1-from-you/#findComment-450101 Share on other sites More sharing options...
laffin Posted January 26, 2008 Share Posted January 26, 2008 means yer using an earlier version of php. array_combine is in php5 now your options are either buiild a array_combine or use multi-dimensional arrays Quote Link to comment https://forums.phpfreaks.com/topic/87964-solved-2-from-me-1-from-you/#findComment-450113 Share on other sites More sharing options...
phpretard Posted January 26, 2008 Author Share Posted January 26, 2008 How do I get PHP 5? Quote Link to comment https://forums.phpfreaks.com/topic/87964-solved-2-from-me-1-from-you/#findComment-450115 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.