0

example:

<img src="img.jpg" alt=""   />

<a href="#" alt=""   />

i want to do someting if the string="alt" exist in the img tag
and someting else if the alt exist in the href tag

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by ofir0803
0

Here's how I would do it (psudo code):

if(strpos($tagString, "alt=") !== false && strpos($tagString, "<img") !== false)
{
     //do img stuff
}
else if((strpos($tagString, "alt=") !== false && strpos($tagString, "<a href=") !== false)
{
      //do href stuff
}
else
{
      //the alt tag either doesn't exist or doesn't exists with img or href
}

or you could:

if(strpos($tagString, "alt=") !== false)
{

if(strpos($tagString, "<img") !== false)
{
     //do img stuff
}
else if(strpos($tagString, "<a href=") !== false)
{
      //do href stuff
}
else
{
      //the alt tag doesn't exists with img or href
}

}
else
{
     //alt tag doesn't exist
}

I hope that helps

Edited by HG&C: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.