Link to home
Start Free TrialLog in
Avatar of burnsj2
burnsj2

asked on

regex question

Does anyone know how I get can the quoted code into an array with just the filenames with PHP/regex.

desiered aray: array(0 => 'tn_21-b196054175f.jpg', 1 => 'tn_21-b196054175.jpg' ... n => 'nth_filename.jpg')

So basically the array just has the filenames from all of the <img> tags (the number of img tags varies, igoring the directory paths and the href.

Thanks!
<a rel="rokzoom" href="components/com_productbook/img_originals/21-b196054175f.jpg">
<img src="components/com_productbook/img_thumbnails/tn_21-b196054175f.jpg" alt="" /></a>
<a rel="rokzoom" href="components/com_productbook/img_originals/21-b196054175.jpg">
<img src="components/com_productbook/img_thumbnails/tn_21-b196054175.jpg" alt="" /></a>
.
.
.
<a rel="rokzoom" href="components/com_productbook/img_originals/nth_filename.jpg">
<img src="components/com_productbook/img_thumbnails/nth_filename.jpg" alt="" /></a>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of tomasgruener
tomasgruener

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tomasgruener
tomasgruener

Oh, I hope you are familiar a bit with regex, how you do the php specific stuff... i havent coded php since years and I'm not very sure, how to use regex on php. but that should be easy.
Avatar of burnsj2

ASKER

This does not seem to work with PHP who's regex's are perl compatible.

My current code:
preg_match_all('src=".*\/([^.|^\/]*.jpg)"',$note,$altResults,PREG_PATTERN_ORDER);
print_r($altResults);

where $note is the input text in the original question. print_r outputs: Array( )
Avatar of burnsj2

ASKER

This regex does seem to work on some platforms, so I'm closing this and will post for a PHP specifc answer.
Thanks,