On Thu, 26 Aug 2004 00:57:43 +0200, in php.general
[EMAIL PROTECTED] (Felix) wrote:

>$array = explode( ' ', chunk_split( $sting, 1, ' ' ) );
>
>http://www.php.net/manual/de/function.explode.php
>http://www.php.net/manual/de/function.chunk-split.php

Well, that would leave a blank entry end of the array:

array(6) {
  [0]=>
  string(1) "0"
  [1]=>
  string(1) "0"
  [2]=>
  string(1) "0"
  [3]=>
  string(1) "0"
  [4]=>
  string(1) "8"
  [5]=>
  string(0) ""
}


Besides, strings containing spaces could also produce unexpected
results (like "foo bar baz"):

array(14) {
  [0]=>
  string(1) "f"
  [1]=>
  string(1) "o"
  [2]=>
  string(1) "o"
  [3]=>
  string(0) ""
  [4]=>
  string(0) ""
  [5]=>
  string(1) "b"
  [6]=>
  string(1) "a"
  [7]=>
  string(1) "r"
  [8]=>
  string(0) ""
  [9]=>
  string(0) ""
  [10]=>
  string(1) "b"
  [11]=>
  string(1) "a"
  [12]=>
  string(1) "z"
  [13]=>
  string(0) ""
}

I would still suggest str_split() if available, otherwise
preg_split().

-- 
- Peter Brodersen

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to