Jump to content

looping values into an array then dislpaying


hellonoko

Recommended Posts

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>';
	}	

 

 

<?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>';
}   
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.