explode doesn't seem to work

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&...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-09-2004
Stijn Goris
 
Posts: n/a
Default explode doesn't seem to work

Hi all,

$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?

Regards
Stijn


Reply With Quote
  #2 (permalink)  
Old 10-09-2004
Daniel Tryba
 
Posts: n/a
Default Re: explode doesn't seem to work

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

Reply With Quote
  #3 (permalink)  
Old 10-09-2004
Stijn Goris
 
Posts: n/a
Default Re: explode doesn't seem to work


"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.


Reply With Quote
  #4 (permalink)  
Old 10-09-2004
Andy Hassall
 
Posts: n/a
Default Re: explode doesn't seem to work

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:45 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0