regex question

Posted on 2008-11-11
Last Modified: 2012-05-05
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.

<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

Question by:burnsj2
    LVL 2

    Accepted Solution

    Try to adapt following:
    If you want to have the directory names:
    If you just want to have the filenames try following pattern:

    I tested it with your source snippet on and it worked fine
    LVL 2

    Expert Comment

    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.
    LVL 1

    Author Comment

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

    My current code:

    where $note is the input text in the original question. print_r outputs: Array( )
    LVL 1

    Author Comment

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

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
    Preface In the first article: A Better Website Login System ( I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now