Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems lisiting items in an array

Status
Not open for further replies.

s0crates9

Technical User
Jun 18, 2005
70
US
I am having problems with my script below. What I want to do essentially. is to grab "<a href>" links and tags and then be able to manipulate them by array variables. I am planning to only echo to screen these tags that exist on a site or page. How do I take what I have below and make it able to do this?

Code:
$url="[URL unfurl="true"]http://www.mywebsite.com";[/URL]
function return_a($url)  {
		 $array = file ($url);
		  for ($i = 0; $i < count($array); $i++)
		  {
			if (preg_match("/<a(.*)href(.*)>(.*)<\/a>/i",$array[$i], $tag_contents))  {
                $atag = array();
				$atag = $tag_contents[$i];
				$atag = strip_tags($atag);
				}
		  }
		  return print_r($array);
	}

I appreciate the help!
 
If you can say what the problems are that you are experiencing that would be easier to solve the problem ?

perhaps you're first problem is that you're variable name is array . array is I believe an reserved word ?
 
No you can have a variable name $array.

You can even make it confusing:
Code:
$array = 'Not an array';
$scalar = array('but','this','is');

Ken
 
I am getting just one <a href> tag and it does not include the complete tag, just what comes after <a href...

I want the tag and every instance of a "<a href" ...


Thanks!
 
Anyone know how to get this routine to return multiple results as opposed to only one?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top