Re: exploding

From: Date: Thu, 26 Aug 2004 15:43:09 +0000
Subject: Re: exploding
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-194808@lists.php.net to get a copy of this message
M. Sokolewicz wrote:
Jake McHenry wrote:
Hi everyone. Is there a way to explode by every character in the variable? Example: $var = "00008"; $test = explode("", $var); output would be $test[0] = 0; $test[1] = 0; $test[2] = 0; $test[3] = 0; $test[4] = 8; Can I get an array like that? Thanks, Jake McHenry MIS Coordinator Nittany Travel http://www.nittanytravel.com 570.748.6611 x108
well, you can access strings like arrays already. So instead of exploding you can already do something like $var = "15 is a number"; $var[2] = 7; echo $var; // will output: 17 is a number same way goes for accessing them In PHP5, the square brackets have been replaced with the curly ones (the square brackets still works, but it's deprecated)
$string = "12345"; echo $string{2}; // 3 -- Daniel Schierbeck

« previous php.general (#194808) next »