Req #75639 [Com]: string2array($str)

From: Date: Wed, 06 Dec 2017 11:40:05 +0000
Subject: Req #75639 [Com]: string2array($str)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212964@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75639&edit=1 ID: 75639 Comment by: spam2 at rhsoft dot net Reported by: web at houhejie dot cn Summary: string2array($str) Status: Open Type: Feature/Change Request Package: *General Issues PHP Version: Next Major Version Block user comment: N Private report: N New Comment: that's why json exists http://at2.php.net/manual/en/function.json-decode.php http://at2.php.net/manual/en/function.json-encode.php Previous Comments: ------------------------------------------------------------------------ [2017-12-06 11:29:11] web at houhejie dot cn Description: ------------ --- From manual page: http://www.php.net/ref.strings --- hope have a function string2array($str) to convert a arrayString to Array, like:"[1,[2-1,2-2]]". we can't use the split() or explode(), although the eval() can do it , but that's very dangerous for uncontrolled data. Test script: --------------- $arr=string2array("[1,[2-1,2-2]]"); Expected result: ---------------- $arr=[1,[2-1,2-2]] ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75639&edit=1

« previous php.bugs (#212964) next »