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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sgarner at gamezone dot co dot nz
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 11:01:34 2025 UTC