Multiple results in regex

This is a discussion on Multiple results in regex within the PHP General forums, part of the PHP Programming Forums category; Hi. I have a string that has multiple references to images in it. I want to pull each reference out ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-31-2007
Philip Thompson
 
Posts: n/a
Default Multiple results in regex

Hi.

I have a string that has multiple references to images in it. I want to pull
each reference out using regex. I've gotten to where I can pull the first
instance out, but not ALL of them. I know each image source starts with
'images/'. I have this so far....

<?php
$pattern = '/[\'\"](images\/[a-z0-9\/\-\_\.]+)[\'\"]/i';
preg_match ($pattern, $string, $matches);
?>

// For example, returns...
Array
(
[0] => "images/some/location/some-image.jpg"
[1] => images/some/location/some-image.jpg
)

This pulls the first instance, but none of the others. I think what the
issue is... is that I am stopping after I get the first one, but I don't
know how to grab the rest. Please help!!

Thanks in advance,
~Philip

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:24 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0