Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#4 str_ireplace does not take length change into account.

<= 0.4
closed-fixed
Harry Fuecks
5
2007-08-12
2006-11-20
Anonymous
No

When using this method, $lstr is used to find matches with the search string, and the numerical positioning results are used to change $str. The problem is that is $search and $replace are not the correct size, then the length of $str will change but the length of $lstr will not. There is no problem when the first match is done, but the second and subsequent matches will fail.

To fix this, the following line should be added at the top of the function:
$lendif = strlen($replace) - strlen($search);
and the line
$matched += $mlen;
should be changed to:
$matched += $mlen + $lendif;

Ian

Discussion

  • Ian
    Ian
    2007-01-24

    Logged In: YES
    user_id=1491439
    Originator: NO

    Any comment on this? Is this a bug that you guys are planning to fix at all?

    Ian

     
  • Harry Fuecks
    Harry Fuecks
    2007-08-12

    Logged In: YES
    user_id=569780
    Originator: NO

    Finally fixed it and included in release 0.5

     
  • Harry Fuecks
    Harry Fuecks
    2007-08-12

    • milestone: --> <= 0.4
    • assigned_to: nobody --> harryf
    • status: open --> closed-fixed