Doc #68943 [Opn->Asn]: Error in documentation for preg_replace
| From: | danack@php.net | Date: | Thu, 29 Jan 2015 19:37:13 +0000 |
| Subject: | Doc #68943 [Opn->Asn]: Error in documentation for preg_replace | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11901@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68943&edit=1
ID: 68943
Updated by: danack@php.net
Reported by: kalimatas at gmail dot com
Summary: Error in documentation for preg_replace
-Status: Open
+Status: Assigned
Type: Documentation Problem
Package: PCRE related
PHP Version: Irrelevant
-Assigned To:
+Assigned To: danack
Block user comment: N
Private report: N
New Comment:
Thanks, I've fixed it. It should show up as the correct version after the next manual build.
I've left it open and assigned to me so I remember to check that it's okay after the
build.
Previous Comments:
------------------------------------------------------------------------
[2015-01-29 11:49:08] kalimatas at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.preg-replace
---
In the example #2 for preg_replace there is a wrong output for the first case (before sorting
arrays). It says the output will be:
The slow black bear jumped over the lazy dog.
But actually it should be:
The bear black slow jumped over the lazy dog.
Test script:
---------------
<?php
$string = 'The quick brown fox jumped over the lazy dog.';
$patterns = array();
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/fox/';
$replacements = array();
$replacements[2] = 'bear';
$replacements[1] = 'black';
$replacements[0] = 'slow';
echo preg_replace($patterns, $replacements, $string);
Output according to docs: The slow black bear jumped over the lazy dog.
Actual output: The bear black slow jumped over the lazy dog.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68943&edit=1