php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10475 Array returned by str_replace unusable.
Submitted: 2001-04-24 13:06 UTC Modified: 2001-04-24 13:08 UTC
From: sbw at sbw dot org Assigned:
Status: Closed Package: *Function Specific
PHP Version: 4.0.4pl1 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sbw at sbw dot org
New email:
PHP Version: OS:

 

 [2001-04-24 13:06 UTC] sbw at sbw dot org
See http://sbw.sbw.org/str_replace/.

str_replace(-string-, -string-, -array-) should return an array.

It appears that it does so, but when the returned array is passed to implode or each, PHP issues warnings:

"Bad arguments to implode()"

"Variable passed to each() is not an array or object"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-24 13:08 UTC] andrei@php.net
It works in latest CVS.

$input = array('foobar', 'barhop');
var_dump(implode(' : ', str_replace('bar', '---', $input)));

Output:
string(15) "foo--- : ---hop"

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 14:01:31 2024 UTC