n00b3 Posted March 22, 2008 Share Posted March 22, 2008 Hello, <?php $somestr = "0,1"; $array = array($somestr); print_r($array); echo count($array); /* The above code prints out the following: Array ( [0] => 0,1 } 1 However, I want the following: Array ( [0] => 0 [1] => 1 } 2 */ ?> How do i get the string "0,1" to act more 'literally'. That is, I would like the string to be the two arguments into the array function rather than just the one "0,1" argument. The variable $somestr can be any variable type. I tried array({$somestr}) {array($somestr)} array((binary) $somestr) But these three attempts resulted in errors or not the desired result. Thanks in advance. DanK Link to comment https://forums.phpfreaks.com/topic/97338-string-to-literal-arguments/ Share on other sites More sharing options...
Barand Posted March 22, 2008 Share Posted March 22, 2008 $array=explode(',' , $somestr); Link to comment https://forums.phpfreaks.com/topic/97338-string-to-literal-arguments/#findComment-498093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.