...

View Full Version : explode delimiter's



seco
10-18-2009, 11:07 AM
is it possible to have no delimiter with an explode, for instance.


$sid = explode("", "1234567");

foreach($sid AS $s){
if($s){
echo ''.$s.'<br>';
}
}

and still have it return

1
2
3
4
5
6
7

thanks.

barkermn01
10-18-2009, 11:48 AM
Yes its verry possible

seco
10-18-2009, 12:48 PM
thanks for the help......

kbluhm
10-18-2009, 12:52 PM
http://www.php.net/str_split

barkermn01
10-21-2009, 12:33 PM
http://www.php.net/str_split

Split is DEAD, GONE POOF, as of PHP6 you have to use explode,

E_DEPRECATED error in php 5.3

kbluhm
10-21-2009, 02:02 PM
Split is DEAD, GONE POOF, as of PHP6 you have to use explode,

E_DEPRECATED error in php 5.3

Well, technically you are correct. And if I would have linked to split(), you would be a hero right now and I would look like a fool.

Buuuuuuttttt... did you click the link? Did you read it properly?

I didn't link to split(), I linked to str_split().

In fact, if you try to explode() using an empty delimiter (as you suggested), well that's just plain not allowed... and you will get an empty delimiter WARNING. And if you had attempted to read the original question, the OP had already tried using explode() -- albeit unsuccessfully -- with an empty delimiter.

There are only two ways to accomplish what was asked:


str_split( $string ); // faster
preg_split( '//', $string ); // slower



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum