Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Does str_replace have limits

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Does str_replace have limits

Postby TopHat » Mon Oct 08, 2012 6:01 am

Hi Everybody,

I have a problem with str_replace that is driving me mad.

This bit of code works, the string is found and replaced.
Code: Select all
$find ='><a href="http://my.url.com/fancy-dress';
$_menu = str_replace($find, ' id="fancy-dress-tab"' . $find, $_menu);


This bit of code does not work (the only addition is a second " in the first line)
Code: Select all
$find ='><a href="http://my.url.com/fancy-dress"';
$_menu = str_replace($find, ' id="fancy-dress-tab"' . $find, $_menu);


$_menu definately contains the string, can anybody spot what I've done wrong? I've tried double quoting the string and escaping the internal "

Are there any limits to str_replace that might be causing my problem

Thanks
TopHat
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Oct 08, 2012 5:48 am

Re: Does str_replace have limits

Postby us2rn4m2 » Mon Oct 08, 2012 8:44 am

No parse error in the first line.

Correction:
Code: Select all
$find  ='><a href="http://my.url.com/fancy-dress';
$_menu = str_replace($find, ' id="fancy-dress-tab"', $find);
echo $_menu;


http://php.net/manual/en/function.str-replace.php
us2rn4m2
New php-forum User
New php-forum User
 
Posts: 17
Joined: Thu Aug 09, 2012 1:28 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.