Re: Odd array problems

From: Date: Fri, 02 Aug 2002 18:16:41 +0000
Subject: Re: Odd array problems
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-86459@lists.php.net to get a copy of this message
My output looks a lot different than yours and I'm not receiving the notices you are. Same script.... only on OSX debug from the CLI. <pre />array(3) { [0]=> string(10) " --<br /> " [1]=> string(6) "<br />" [2]=> string(11) "After delim" } End of script CVS HEAD from earlier this morning (arond 9 am EST). On Fri, 2 Aug 2002, Chuck Hagenbuch wrote: > With latest CVS (HEAD branch, checked out 10 or so minutes ago), the > following script: > > <?php > > error_reporting(E_ALL); > $text = "Before delim.<br />\n--<br />\nAfter delim"; > > $parts = preg_split('|(\n--\s*(<br />)?\n)|', $text, 2, > PREG_SPLIT_DELIM_CAPTURE); > $text = array_shift($parts); > if (count($parts)) { > echo '<pre />'; var_dump($parts); > $text .= $parts[0]; > $text .= $parts[2]; > } > > ?> > > Gives me this output: > > array(3) { > [0]=> > string(10) " > -- > " > [1]=> > string(6) "" > [2]=> > string(11) "After delim" > } > > Notice: Undefined offset: 0 in /var/www/array.php on line 10 > > Notice: Undefined offset: 2 in /var/www/array.php on line 11 > > ---- > > But the var_dump() clearly shows that there _are_ elements 0 and 2 in > the array. What am I missing, or is something still off with the array > code? > > -chuck > > -- > "hello, I'm a giant cheese, and I'm here to give you a therapeutic massage" > > >---------------------------------------------------------------< Dan Kalowsky "A little less conversation, http://www.deadmime.org/~dank a little more action." dank-nos@mpa-deadmime.org - "A Little Less Conversation", kalowsky@php.net Elvis Presley

« previous php.dev (#86459) next »