I have this simple line of php
$text = preg_replace("/\\ii(.*?)\\<>/", "<img scr='img/$1'>", $text);
Where I change II30.jpgII to <img scr='img/30.jpg'>, and it works fine.
But what I need, is to also check if there is a file called 30.txt, and if so, print the text below the image. I simply can't figure out how do do that - maybe I'm all wrong using preg_replace anyway?
What I acually need is a way to change \<img>30.jpg\<img> to <img scr='img/30.jpg'>, but I could not figure out how to search for \<img> so ended up using II instead :-)
And then call a function image_text_print("img/30.txt"), if the file exists, insert the return just below the image.
It not so well explained, but I hope you understand what I look for :-)
Edit
Instead maybe I should somehow search the $text for xxxxx, and then
- check for file xxxxx.txt
- read the file xxxxx.txt file
- make the changes in $text to
- (text from xxxxx.txt file)
But I can't figure out how to search for content between multiple and , in $text :-/
Jorgensen
preg_replace('/\\\\<img>(.*?)\\\\<img>/', "<img scr='img/\$1'>", $text)?$beskrivelse? See 3v4l.org/i4CeR to understand how it works.