If you want to use a regex to parse the string:
<a href="javascript:void(EXTERNALLINK('102'))">
and get back the ID portion, try doing this:
$strlink = "<a href=\"javascript:void(EXTERNALLINK('102'))\">";
## note, you may want to double check my regex syntax. but hopefully
## you will get the idea based on the explanation found in the
## <snip> explanation of the eregi function and the 3rd parameter
if ( eregi( "EXTERNALLINK\(\'([0-9]*)\'\)", $strlink, $arr ) )
{
$ids[] = $arr[1]; ## fill the $ids array with the id
}
============see below for explanation about using the regex function
<snip src="http://www.php.net/manual/en/function.eregi.php">
<info>
eregi
(PHP 3, PHP 4 >= 4.0.0)
eregi -- case insensitive regular expression match
</info>
<syntax>
int eregi ( string pattern, string string [, array regs])
</syntax>
<explanation>
If matches are found for parenthesized substrings of pattern and the
function is called with the third argument regs, the matches will be
stored in the elements of the array regs. $regs[1] will contain the
substring which starts at the first left parenthesis; $regs[2] will
contain the substring starting at the second, and so on. $regs[0] will
contain a copy of the complete string matched.
</explanation>
<example>
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
echo "$regs[3].$regs[2].$regs[1]";
} else {
echo "Invalid date format: $date";
}
</example>
</snip>
Hope this helps somewhat or for other things,
Nicole
www.aeontrek.com
=======================
R.S. Herhuth wrote:
> I have an instance where I have an article ($article) that may or may
> not contain:
>
> <a href="javascript:void(EXTERNALLINK('102'))">
>
> There might be many occurrances of this substring in exactly the same
> format but the id's will be unique with each occurance.
>
> Can someone please show me how to extract the id's (in this case the
> 102) of the above string into an array? I have been through the
> documentation on substrings and regular expressions but I'm just not
> getting it.
>
> Thanks,
> Ron
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php