php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #6326 preg_replace does not support 'limit' argument
Submitted: 2000-08-24 00:21 UTC Modified: 2000-08-24 09:51 UTC
From: sgarner at gamezone dot co dot nz Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.1pl2 OS: TurboLinux Server 6.0 (kernel 2.
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
4 + 26 = ?
Subscribe to this entry?

 
 [2000-08-24 00:21 UTC] sgarner at gamezone dot co dot nz
The documentation for preg_replace says the function supports four arguments: pattern, replacement, subject, and limit. However, PHP (4.0.1pl2) does not appear to support the last argument, limit.

Script:

<?php
   $subject = "The tiger ate plants while a tiger watched.";
   echo preg_replace("/tiger/", "giraffe", $subject, 1);
?>

Expected output:

   The giraffe ate plants while a tiger watched.

Actual output:

   Warning: Wrong parameter count for preg_replace() in dir/file.php on line 2


phpinfo() shows:

PCRE (Perl Compatible Regular Expressions) Support: enabled
PCRE Library Version: 3.1 09-Feb-2000.
Configure Command: ./configure' '--with-apache=../apache' '--with-mysql=/usr/local/mysql' '--without-gd' '--without-ttf' '--with-ftp' '--with-xml' '--with-config-file-path=/etc' '--disable-debug' '--enable-track-vars=yes'


Regards,
Simon Garner

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-24 09:03 UTC] andrei@php.net
That parameter was added after 4.0.1pl2.

 [2000-08-24 09:10 UTC] jmoore@php.net
This is not mentioned in the manual at all and should be, there is no note saying limit was added after 4.0.1pl2, Reopened and changed to docu bug
 [2000-08-24 09:51 UTC] jmoore@php.net
Had some time so did it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 02:01:31 2024 UTC