Jump to content

Help Needed Converting eregi_replace Function To preg_replace For PHP 5.3


annuity

Recommended Posts

Hi,

 

Since upgrading to php 5.3 i have a line of code on  my site that is giving me a depreciated error. The line of code is as follows:

 

$data=eregi_replace(">"."[[:space:]]+"."<","><",$data);

 

I've got as far as knowing i need to change it from eregi_replace to preg_replace but i can't for the life of me work out where to put any backslashes etc, if any. Is there a formula for working this type of thing out? Every example i see has backslashes and $1's all over the place. Do i simply do this "/ and this /" after and before every double quote? Or is it not as simple as that? Things never are are they!

 

Please could an expert on here offer me any assistance. This is an important line of code(i think) so i didn't want to experiment as i would normally do, i need to get this right first time as i don't know what will happen if i get this wrong.

 

Cheers.

Link to comment
Share on other sites

No way google has indexed this thread already! wow! I was searching for a formula to work out where to put the backslashes and the first result is this thread! To be honest that doesn't bode well for me being able to find a formula for newbies like myself to try and work out how to convert the function but i'll keep going.

 

If anyone can help me convert this line of code to preg_replace it would be much appreciated.

 

$data=eregi_replace(">"."[[:space:]]+"."<","><",$data);

 

I'm thinking along the lines of

$data=preg_replace("/>/"."/[[:space:]]+/"."/</","/></",$data);

but i'm not sure and as i say i need to get this right.

 

Cheers.

Link to comment
Share on other sites

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.