Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 559217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:12:54+00:00 2026-05-13T12:12:54+00:00

as a warning I have very limited experience with PHP, with just over 1

  • 0

as a warning I have very limited experience with PHP, with just over 1 month of learning it.

I have a textform that when its submitted it goes through str_replaces on the allowed tags (eg [img]) to turn them into html tags.

What I want to do Is grab the URLS from the $string and add links to the original image and the url to the resized. What im basically asking, i guess, is how do i grab urls from a string? so that I can use them to add links to resized imgs.

<a href="linkToOriginal"><img src=""location/resize.php?file=', $string);`

what i do at the moment is just replace [img] with html img tag which is put right next to the url in the text field. $string being the large body of text.

 $imageOpen = str_replace('[img]', '<img src="http://location/resize.php?file=', $string);
   $imageClose = str_replace('[/img]', '"/></a>', $imageOpen);

If this isnt clear please tell me, as im pretty awful at explaining things!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:12:54+00:00Added an answer on May 13, 2026 at 12:12 pm

    I think you could better use some regular expressions here.. str_replace is to limited for this matter.
    When you use regular expressions you can open and close the tag in one replace with the value you want.
    You could take a look at this for instance:

        // images
    $string = preg_replace("_\[img](.*)\[/img\]_si", '<img src="$1" alt="Image" />', $string);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Warning: I have very little JavsScript experience. In my past programming experience, I usually
WARNING: I have been learning Python for all of 10 minutes so apologies for
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035
I have a warning and just can't work out how to make it go
I have just written my own logging framework (very lightweight, no need for a
Im very new to php and i have a page with 5 includes located
I have an NSTimer that I initialize with scheduledTimerWithTimeInterval: with a very short interval
I am very much outdated, but I have just upgraded my project to use
I'm very new to PHP. I have a line of code on a server
Warning: I am still very new to NHibernate and Fluent! I have a mapping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.