|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2013-03-17 03:57 UTC] valentiny510 at yahoo dot es
[2013-03-17 16:13 UTC] rasmus@php.net
[2013-03-17 16:13 UTC] rasmus@php.net
-Status: Open
+Status: Analyzed
-Package: Feature/Change Request
+Package: *General Issues
[2013-03-17 16:44 UTC] paulschreiber at gmail dot com
[2013-04-03 23:05 UTC] jeff at lxvi dot net
[2014-12-30 15:12 UTC] tyrael@php.net
-PHP Version: 4.4.4
+PHP Version: 7.0
[2015-01-06 12:47 UTC] francois@php.net
-Status: Analyzed
+Status: Assigned
-Assigned To:
+Assigned To: francois
[2017-10-24 07:08 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: francois
+Assigned To:
[2018-02-11 17:58 UTC] cmb@php.net
-Package: *General Issues
+Package: Strings related
[2020-04-01 16:01 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2020-04-01 16:01 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
Description: ------------ The PHP docs for str_replace say: "If search and replace are arrays, then str_replace() takes a value from each array and uses them to do search and replace on subject. If replace has fewer values than search, then an empty string is used for the rest of replacement values. If search is an array and replace is a string, then this replacement string is used for every value of search. The converse would not make sense, though." I think the converse makes sense in some cases. Here is an example: $result = str_replace("?", array("Joe", "Smith"), "SELECT * FROM people WHERE first = ? AND last = ?"); (Yes, if you were doing real database work, you'd need to escape everything.) It would be nice if PHP supported this. Reproduce code: --------------- $result = str_replace("?", array("'Joe'", "'Smith'"), "SELECT * FROM people WHERE first = ? AND last = ?"); print $result; Expected result: ---------------- SELECT * FROM people WHERE first = 'Joe' AND last = 'Smith' Actual result: -------------- PHP Notice: Array to string conversion in /Users/paul/- on line 2 Notice: Array to string conversion in /Users/paul/- on line 2 SELECT * FROM people WHERE first = Array AND last = Array