Skip to main content
added 2 characters in body
Source Link
C3roe
  • 97.6k
  • 15
  • 100
  • 172

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

I have this simple line of php

$text  = preg_replace("/\\ii(.*?)\\<>/", "<img scr='img/$1'>", $text);

Where I change II30.jpgII to , 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

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

added 409 characters in body
Source Link

I have this simple line of php

$text  = preg_replace("/\\ii(.*?)\\<>/", "<img scr='img/$1'>", $text);

Where I change II30.jpgII to , 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

I have this simple line of php

$text  = preg_replace("/\\ii(.*?)\\<>/", "<img scr='img/$1'>", $text);

Where I change II30.jpgII to , 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 :-)

I have this simple line of php

$text  = preg_replace("/\\ii(.*?)\\<>/", "<img scr='img/$1'>", $text);

Where I change II30.jpgII to , 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

added 2 characters in body
Source Link
Laurel
  • 6.2k
  • 14
  • 35
  • 60

I have this simple line of php $text = preg_replace("/\ii(.*?)\<>/", "", $text);

$text  = preg_replace("/\\ii(.*?)\\<>/", "<img scr='img/$1'>", $text);

Where I change II30.jpgII to , 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>\<img>30.jpg\<img> to <img scr='img/30.jpg'>, but I could not figure out how to search for <img>\<img> so ended up using II instead :-)

And then call a function image_text_print("img/30.txt")image_text_print("img/30.txt"), if the file exsistsexists, insert the return just below the image.

It not so well explained, but I hope you understand what I look for :-)

Jorgensen

I have this simple line of php $text = preg_replace("/\ii(.*?)\<>/", "", $text);

Where I change II30.jpgII to , 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 , 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 exsists, insert the return just below the image.

It not so well explained, but I hope you understand what I look for :-)

Jorgensen

I have this simple line of php

$text  = preg_replace("/\\ii(.*?)\\<>/", "<img scr='img/$1'>", $text);

Where I change II30.jpgII to , 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 :-)

Source Link
Loading