Well, title says it all.
I'm trying to learn some string functions.
I thought I had an understanding, but I am stuck.
I have code that pulls in information from a website and I'm trying to pull out pieces. I have it working for some of the pieces, but not this one.
This is the part of the html that I am working with.
Released by </TD><TD BGCOLOR="#FFFFFF" colspan=2><A HREF="/cg/avg.dll?p=avg&sql=10: D|||919Warner|Brothers">Warner Brothers</A></TD></TR><tr><TD Width=140 Align=Right BGCOLOR="#54CFFE">See Also
I'm trying to pull out Warner Brothers from that text. Its from the www.allmovieguide.com website. The Warner Brothers is variable based on what the studio the movie is from.
The problem I'm having is that the
<A HREF
part is different. How can I have a variable function that will pull out the text between the end of the
<A HREF
part and the
</A>
?
So, I have the following code
function trimString($string, $start, $end, $grabLast = false)
{
$startPosition = strpos($string, $start);
if ($startPosition === false) return (false);
$string = substr($string, $startPosition + strlen($start));
if ($grabLast && ereg($start, $string)) return(trimString($string, $start, $end, $grabLast));
$endPosition = strpos($string, $end);
if ($endPosition === false) return (false);
$string = substr($string, 0, $endPosition);
return trim($string);
}
And here is the code to grab the part of the string.
if (($releaseStudio == "Select one") && ($allmovieguide != ""))
{
$URL = 'http://www.allmovie.com/cg/avg.dll?p=avg&sql=1:' . $allmovieguide;
$Allmovieguide = (($allmovieguide) ? fetchURL($URL) : NULL);
$releaseStudio = trimString($Allmovieguide, '">', '</A></TD></TR><tr><TD Width=140 Align=Right BGCOLOR="#54CFFE">See Also');
Its returning a blank value.
Any help is greatly appreceiated.