Req #74874 [Opn->Nab]: You can not typecast through array_map
Edit report at https://bugs.php.net/bug.php?id=74874&edit=1
ID: 74874
Updated by: fmargaine@php.net
Reported by: body00 at gmail dot com
Summary: You can not typecast through array_map
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: Arrays related
Operating System: All
PHP Version: 7.1.7
Block user comment: N
Private report: N
New Comment:
As explained by pmmaga, this is not a bug.
Previous Comments:
------------------------------------------------------------------------
[2017-07-07 09:30:01] 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:18:31] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74874&edit=1
Thread (3 messages)