By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,441 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,441 IT Pros & Developers. It's quick & easy.

explode doesn't seem to work

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Stijn Goris <me*****@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

Jul 17 '05 #2

P: n/a

"Daniel Tryba" <ne****************@canopus.nl> wrote in message
news:ck**********@news.tue.nl...
Stijn Goris <me*****@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.
Jul 17 '05 #3

P: n/a
On Sat, 9 Oct 2004 15:06:36 +0200, "Stijn Goris" <me*****@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 / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.