Jump to content

Recommended Posts

Hi there,

I have a field of a mysql db with this kind of data

EXAMPLE
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
<p>MPLA MPLA MPLA MPLA σαδηασηασδ ηασδ ηασδ ηασδη ασηασδηασδη ασδ ησαδη ασδησαδη ασδ ηασδ ηασδηασδ ηασδγη ασδηασδηασδη ασδ ηασδ ησαδηασηασδ ηασδ ηασδ ηασδη ασηασδηασδη ασδ ησαδη ασδησαδη ασδ ηασδ ηασδηασδ η</p>
<p align="center"><img width="1280" height="1024" src="/UserFiles/Image/AngelinaJolie77ee17_f1280.jpg" alt="" style="width: 498px; height: 395px;" /></p>
<p>ασδγη ηασδ ησαδηασηασδ ηασδ ηασδ ηασδη ασηασδηασδη ασδ ησαδη ασδησαδη ασδ ηασδ ηασδηασδ η</strong></p>[/quote]

This field's data came from a webform with a wysiwyg editor field

I want to replace the " /UserFiles " with an absolute url for example " [a href=\"http://localhost/UserFiles"\" target=\"_blank\"]http://localhost/UserFiles"[/a]

How can I do it? I suppoce there is a string replacement function.The one that I found in php.net its not the thing i want. One way to do it is to do the replacement before inserting the data to the db. Can you help me with it?

The basic problem is that I need all relative links to be absolute in this field..

Thank you very much in advance
Link to comment
https://forums.phpfreaks.com/topic/4466-about-string-replacement/
Share on other sites

I think what you might be looking for is a combination of the replace function you found on php.net .. and regular expressions, which are also available on php.net. I can help you further, but read up first and come back with more specific questions :)
[!--quoteo(post=352988:date=Mar 8 2006, 09:06 PM:name=demon_athens)--][div class=\'quotetop\']QUOTE(demon_athens @ Mar 8 2006, 09:06 PM) [snapback]352988[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Lets make it spesific then...

" How can I find a string and replace it with another given string in a variable?"

better?
[/quote]

Ouch. Attitude.

Well let me explain. Regular expressions can help you find the string ESPECIALLY IF IT IS DYNAMIC, I.E. you dont know what will be between [i]src="<here>"[/i]

once you find that location OR the data reference [i]"<here>"[/i] you can easily replace the data with what you need it to be, and, using the same method, check to see IF it is already an absolute link.

The reason I am not just giving you code is you can easily copy and paste it and not learn anything.. I am not trying to be a teacher, but what happens if you need this help again? That's why I gave you 2 topics to go read on..
As I allready said the code I am looking for is always starting with "/UserFiles/". So I know the string tha must be search and replaced.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]The reason I am not just giving you code is you can easily copy and paste it and not learn anything.. I am not trying to be a teacher, but what happens if you need this help again?
[/quote]

Well, you are trying to be a teacher and I am not so stupid to come back with the same problem.


Anyway my first though was to use Blow to blow the string and then remake it with the new absolute one( after each blow). The only reason I turned to this forum was because it seemed pretty much code ( and maybe heavy) for such an easy function.. So I asked and your answer was " Go and read mister!'

Well, ok. Thanks ( this may explain my "attitude")
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.