473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Jul 17 '05 #1
3 3302
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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Richard Lawrence | last post by:
Hi there, I'm having a problem with PHP which I'm not sure how to best solve. Here is the code: $fp = fopen("comments.txt", "r"); while(!feof($fp)) { $line = fgets($fp, 1024); list($key,...
5
by: FFMG | last post by:
Hi, I need the php equivalent of explode in one of my app. I read a very big file and "explode" each line to fill a structure. The reading of the file, 19Mb, (I will also need to streamline...
9
by: mosesdinakaran | last post by:
Hi All, Have a look at the following code $test = explode('-','one-two-three-four-five'); print_r($test); Output: Array (
0
by: k04jg02 | last post by:
Python has a nifty operator that will take a container and pass its elements as function parameters. In Python you can make a list like so: x = Then you can say: f(*x)
2
tolkienarda
by: tolkienarda | last post by:
hi everyone i am getting a bunch of values from a form via post all of the information that this question deals with is from series of check boxes below is the code that creates the check boxes...
1
by: 848lu | last post by:
PHP - display from txt file with explode function hi, i am trying to display all data from a txt file with a function of explode but does not work..... <? #reads a text file outputs it to...
8
by: Jack | last post by:
I would like to Explode a string into an array that does not begin at 0 but I can't get it to work. For example: $MyInfo = array(1 =27,68,31,19,40); will result in $MyInfo = 27 ... $MyInfo = 40...
5
by: sathyashrayan | last post by:
Dear group, The function to be used as follows: $links = "http://www.campaignindia.in/feature/analysis"; $tag1 = '<div class=feature-wrapper>'; $tag2 = '<h1><a href'; $tag3 = "</a>"; $op =...
8
by: vinpkl | last post by:
hi all i want to use explode url for shotening my urls i have a url like http://localhost/vineet/products.php?dealer_id=12&category_id=2 This is my navigation php code that has url...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.