This is a discussion on explode doesn't seem to work within the PHP Language forums, part of the PHP Programming Forums category; Hi all, $ttt = array(); $ttt = explode("-", "test-niet"); echo "$ttt[0] | $ttt[1]<br&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Stijn Goris <mepisto@hotmail.com> wrote:
> $ttt = array(); > $ttt = explode("-", "test-niet"); > echo "$ttt[0] | $ttt[1]<br>"; > > Should give > test | niet > > but gives > > test-niet | Where can we admire this behavior? Running above code (after adding print_r): $ php4 <?php $ttt = array(); $ttt = explode("-", "test-niet"); echo "$ttt[0] | $ttt[1]<br>"; print_r($ttt); ?> test | niet<br>Array ( [0] => test [1] => niet ) $ Proof it works perfectly like expected. -- Daniel Tryba |
|
|||
|
"Daniel Tryba" <news_comp.lang.php@canopus.nl> wrote in message news:ck8o8i$bre$1@news.tue.nl... > Stijn Goris <mepisto@hotmail.com> wrote: >> $ttt = array(); >> $ttt = explode("-", "test-niet"); >> echo "$ttt[0] | $ttt[1]<br>"; >> >> Should give >> test | niet >> >> but gives >> >> test-niet | > > Where can we admire this behavior? > > Running above code (after adding print_r): > $ php4 > <?php > $ttt = array(); > $ttt = explode("-", "test-niet"); > echo "$ttt[0] | $ttt[1]<br>"; > print_r($ttt); > ?> > test | niet<br>Array > ( > [0] => test > [1] => niet > ) > $ > > Proof it works perfectly like expected. > > -- > > Daniel Tryba > Is seems to work now. Probably has to do with a caching problem. I m working on a remove server and the old code was maybe still in use. |
|
|||
|
On Sat, 9 Oct 2004 15:06:36 +0200, "Stijn Goris" <mepisto@hotmail.com> wrote:
> $ttt = array(); > $ttt = explode("-", "test-niet"); > echo "$ttt[0] | $ttt[1]<br>"; > >Should give >test | niet > >but gives > >test-niet | > >Which meens the string is cut into 2 pieces. Someone knows what i m doing >wrong? As Daniel Tryba points out, the code you posted gives the _expected_ output you posted, not the output you said it gives. So, it's either a particularly silly bug in your version of PHP (which are you using?) or we're not seeing the actual problem here. Here's a completely wild guess - the data where this actually happens has come from someone who's been using Microsoft Word, and instead of there being a '-' dash character, Word's replaced it with an em-dash, which is a different character. -- Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool |