SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question str_replace size .....

    Hi!
    Does somebody know how big strings i can use in str_replace?

    mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

    how big can be the $search string and how big can be the $replace string?
    E: and $subject also

  2. #2
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    The string can be any size, it could be a large paragraph. But if you have a large number of pages to search through it may take some time to find and replace what you want.
    "Don't you just love it when you solve a programming bug only to create another."

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    tnx for quick replay.

    I have problem in system what i'm developing. it is old and big and
    the system stops in a certain place always.
    and on that place there is the row:

    $XML = str_replace($file, $this->$func($file), $XML);

    where the sizes are following: 78084 / 0 / 84808 as strlen() is giving.

    Can it be, that the sizes are too big for checking and memory will get over?
    Or any other suggestion why it stops in that certain row?

  4. #4
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Strange, have you done a strlen() on the file in question? If so whats the number?
    "Don't you just love it when you solve a programming bug only to create another."

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    strlen for file gives: 78084
    strlen for $XML gives: 84808

    unfortunatly its not my code but i have to fix it

    Long time ago i was thinking the problem was about memory using. but now when system has 128MB to use and it is using around 14MB before that line, then i do not think so.

  6. #6
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Does it give an error code? Also, can we see a snipet of code used?
    "Don't you just love it when you solve a programming bug only to create another."

  7. #7
    SitePoint Addict
    Join Date
    Sep 2005
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your host (or your own configuration) may be limiting the amount of memory PHP can use no matter how much your server has. You can check phpinfo() or view your php.ini file.
    PHP Shopping Cart Software Easy Ecommerce Shopping Cart Script.
    PHP Super Cart is 100% template driven.

  8. #8
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok. Found that the problem is not in str_replace but preg_replace.
    tnx, for helping. topic closed.

    Have to fint now solution, why preg_replace is not working


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •