hellonoko Posted March 21, 2009 Share Posted March 21, 2009 My below code loops retrieved URLs into a array while displaying them. The URLs display correctly so I know my function is working however I must be storing them to the array or trying to display them wrong because that part of my code does not work. What am I doing wrong here? for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $url = $href->getAttribute('href'); echo '<b>'.$links = $clean_link = checkURL( $url, $target_url).'<b>'; echo '<br>'; } echo count($links); foreach ($links as $link) { echo $link; echo '<br>'; } Link to comment https://forums.phpfreaks.com/topic/150433-looping-values-into-an-array-then-dislpaying/ Share on other sites More sharing options...
rhodesa Posted March 21, 2009 Share Posted March 21, 2009 <?php $links = array(); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i)->getAttribute('href'); $clean_link = checkURL( $url, $target_url); $links[] = $clean_link; echo '<b>'.$clean_link.'<b><br>'; } echo count($links); foreach ($links as $link) { echo $link.'<br>'; } ?> Link to comment https://forums.phpfreaks.com/topic/150433-looping-values-into-an-array-then-dislpaying/#findComment-790095 Share on other sites More sharing options...
hellonoko Posted March 21, 2009 Author Share Posted March 21, 2009 Thanks but only returns the $target_url So all the link are exactly the same. $target_url is the base URL of the links I am going through but maybe I can figure it out from here. Link to comment https://forums.phpfreaks.com/topic/150433-looping-values-into-an-array-then-dislpaying/#findComment-790098 Share on other sites More sharing options...
rhodesa Posted March 21, 2009 Share Posted March 21, 2009 what does the checkURL function do? Link to comment https://forums.phpfreaks.com/topic/150433-looping-values-into-an-array-then-dislpaying/#findComment-790103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.