Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Brainstorming Session

Status
Not open for further replies.

Eloff

Programmer
Aug 29, 2001
78
CA
Ok lets think here. Split involves splitting a string around a certain item or section. But how do you extract all of the occurances of a certain type of item from a string? If I have a user inputted string with a lot of html and occasionally some numbers ($ values and regular numbers). Is there an easy way to do this? Age: 17
School: Alberta Distance Learning Center
Location: British Columbia, Canada
If at first you dont't succeed, try, try again. - programmer's motto.
 
Ok I think preg_match_all is the thing to use. However I can't figure out how to make it work.

Here's my script:

<?
$spy = &quot;testing 123 testing&quot;;
preg_match_all (&quot;/\d+/&quot;,&quot;$spy&quot;, $spy_pieces);

foreach ($spy_pieces as $piece) {
echo &quot;$piece&quot;;
}

?>

Heres the output:
ArrayArray Age: 17
School: Alberta Distance Learning Center
Location: British Columbia, Canada
If at first you dont't succeed, try, try again. - programmer's motto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top