php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #74874 You can not typecast through array_map
Submitted: 2017-07-07 09:18 UTC Modified: 2017-07-07 09:33 UTC
From: body00 at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 7.1.7 OS: All
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:
49 - 26 = ?
Subscribe to this entry?

 
 [2017-07-07 09:18 UTC] body00 at gmail dot com
Description:
------------
When you try to typecast the values of an array such as 
$myArray=array_map("(string)",$myArray)
transforms $myArray into NULL

Test script:
---------------
$myArray=array(123,246);
$myArray=array_map("(string)",$myArray);


Expected result:
----------------
$myArray=array("123","246");

Actual result:
--------------
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-07 09:30 UTC] mail at pmmaga dot net
The cast itself is not a function. Using strval you can accomplish what you are looking for.

$myArray=array_map("strval",$myArray);
 [2017-07-07 09:33 UTC] fmargaine@php.net
-Status: Open +Status: Not a bug
 [2017-07-07 09:33 UTC] fmargaine@php.net
As explained by pmmaga, this is not a bug.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Feb 25 19:01:28 2020 UTC