rgb192
asked on
many rows of html text, want a value from each line
text here<a href="/start.php?a=request -link& s=new-york &f=int ake&l= want-this- number"><i mg src="/images/start.gif" alt="Start"></a>more text here
text here<a href="/start.php?a=request -link& s=new-york &f=int ake&l= want-this- number"><i mg src="/images/start.gif" alt="Start"></a>more text here
text here<a href="/start.php?a=request -link& s=new-york &f=int ake&l= want-this- number"><i mg src="/images/start.gif" alt="Start"></a>more text here
text here<a href="/start.php?a=request -link& s=new-york &f=int ake&l= want-this- number"><i mg src="/images/start.gif" alt="Start"></a>more text here
text here<a href="/start.php?a=request -link& s=new-york &f=int ake&l= want-this- number"><i mg src="/images/start.gif" alt="Start"></a>more text here
many lines
please tell me how to get
want-this-number
text here<a href="/start.php?a=request
text here<a href="/start.php?a=request
text here<a href="/start.php?a=request
text here<a href="/start.php?a=request
many lines
please tell me how to get
want-this-number
You could also be more flexible in the URLs you accept, such as:
preg_match_all('#<a href="/start\.php[^"]*(?:\?|&)l=(\d+)#',$text,$matches);
print_r($matches[1]);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Terry's code
Array ( ) Array ( [0] => Array ( ) )
Array ( ) Array ( [0] => Array ( ) )
<?php
$text = <<<EOD
text here<a href="/start.php?a=request-link&s=new-york&f=intake&l=want-this-number"><img src="/images/start.gif" alt="Start"></a>more text here
text here<a href="/start.php?a=request-link&s=new-york&f=intake&l=want-this-number"><img src="/images/start.gif" alt="Start"></a>more text here
text here<a href="/start.php?a=request-link&s=new-york&f=intake&l=want-this-number"><img src="/images/start.gif" alt="Start"></a>more text here
text here<a href="/start.php?a=request-link&s=new-york&f=intake&l=want-this-number"><img src="/images/start.gif" alt="Start"></a>more text here
text here<a href="/start.php?a=request-link&s=new-york&f=intake&l=want-this-number"><img src="/images/start.gif" alt="Start"></a>more text here
EOD;
preg_match_all('#<a href="/start\.php[^"]*(?:\?|&)l=(\d+)#',$text,$matches);
print_r($matches[1]);
preg_match_all('#(?<=<a href="/start\.php\?a=request-link&s=new-york&f=intake&l=)\d+#',$text,$matches);
print_r($matches);
ASKER
Ray has the correct answer, not sure if Terry has correct answer
I opened another question asking why Ray's code works
https://www.experts-exchange.com/questions/28161784/first-part-of-parsing-many-lines.html
I opened another question asking why Ray's code works
https://www.experts-exchange.com/questions/28161784/first-part-of-parsing-many-lines.html
ASKER
did I implement Terry's code correctly?
ASKER
Ray had the only answer that I knew how to use.
Thanks
Thanks
Open in new window