Page 1 of 1
strpos()
Posted: Wed Nov 09, 2005 2:33 am
by traffic
Hello...
If I have defined $pos as:
How can I find the number of characters between $pos and the next ">"...
Example:
Code: Select all
<a id="_ctl4_hlMCR" href="/Assessor/ParcelApplication/plat_redirect.asp?txtBookNo=586&txtPageNo=25&selType=Plat" target="_blank">58625</a>
The above $pos will put me right after "id=" - I need to 'add' the number of characters from "id=" through the first ">"...
The idea is to strip out the "58625"...
Thank you for any help you can give me...
...
Posted: Wed Nov 09, 2005 3:34 am
by Grim...
Code: Select all
$data = "<a id=\"_ctl4_hlMCR\" href=\"/Assessor/ParcelApplication/plat_redirect.asp?txtBookNo=586&txtPageNo=25&selType=Plat\" target=\"_blank\">58625</a>";
$posa = strpos ( $data, ">");
$posb = strpos ( $data, "<", 2);
$length = $posb - $posa;
$strip = substr($posa, $length);
$data = str_replace($strip, "", $data);
If you actually wanted to keep the '58625' then it is $strip.
There are better ways to do this using Regex.
strpos()
Posted: Wed Nov 09, 2005 9:13 am
by traffic
Grim...
I am interested in finding a better way to do this...
The reason I was asking about the finding the 'next' ">" is that I do not know what the string is...
Code: Select all
<a id=\"_ctl4_hlMCR\" href=\"/Assessor/ParcelApplication/plat_redirect.asp?txtBookNo=586&txtPageNo=25&selType=Plat\
The only part that I know will be there is the "_ctl4_hlMCR"...
Posted: Wed Nov 09, 2005 10:12 am
by Grim...
Are you stripping content from other peoples websites?
Content
Posted: Wed Nov 09, 2005 10:38 am
by traffic
Yes - I am stripping public records content for personal use...
...
Posted: Wed Nov 09, 2005 11:43 am
by josh
I would suggest regular expressions pattern matching, if you are new to this start with something simpler like matching an email