Req #74874 [Opn->Nab]: You can not typecast through array_map

From: Date: Fri, 07 Jul 2017 09:33:17 +0000
Subject: Req #74874 [Opn->Nab]: You can not typecast through array_map
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209889@lists.php.net to get a copy of this message
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)

« previous php.bugs (#209889) next »