Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

find a "imagefilename.jpg"  in a text with php

Posted on 2011-02-26
5
Medium Priority
?
228 Views
Last Modified: 2012-05-11
How to find a image filename in a text with php to make an embeded image  ?....

Well, I do have an exported text (a diary) in plain text ... in this text there are filenames of the images attached to the specific day .. how can I replace the filename with a new <img src="thefile.jpg"> with php?
And how can I make a CSS to style it? ... first line = h2 etc ...

Source

Monday 23rd of May
=================
This is the day. The sun is bright and live is good

Photos: IMG00283750.jpg, IMG985749.jpg


0
Comment
Question by:Hans Inge Hagen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 34988855
What is the entry pattern ? I mean is it always:
TITLE
==================
TEXT TEXT TEXT
-EMPTY LINE-
Photos: a.jpg, b.jpg

Open in new window


Could the images appear in two or more lines ? Can they be separated with empty line ?
0
 

Author Comment

by:Hans Inge Hagen
ID: 34988882
No. We need to search for the xxxx.jpg filename in all the text ... when found we need to add the tags to embed the image .. Example:  IMG_0001.jpg  converted to  <img src="IMG_0001.jpg">
0
 
LVL 4

Expert Comment

by:LAMASE
ID: 34988915
preg_replace('/ ([^ ]+\.jpg)/i','<img src="$0" />',$text);

Open in new window

0
 
LVL 4

Accepted Solution

by:
LAMASE earned 200 total points
ID: 34988921
sorry, use $1 instead of $0
0
 

Author Closing Comment

by:Hans Inge Hagen
ID: 34988953
Very good! Thanks a milliion
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

688 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