Split

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
traffic
Forum Newbie
Posts: 17
Joined: Fri May 23, 2003 1:18 pm

Split

Post by traffic »

hello...

I have a piece of code that I can't seem to get to work properly...

Code: Select all

$dat = "May 23, 2003||100"

list ($date, $count) = split ('ї||]', $dat);
I can't seem to split correctly on "||"...

the variable --> $count always comes out as blank no matter what it equals to...

The complete code is:

Code: Select all

$fil = fopen("$counter", r);  
        $dat = fread($fil, filesize("$counter"));
        fclose($fil); 
        list ($date, $count) = split ('ї||]', $dat); 
        $fil = fopen( "$counter", w); 
        $count++;
        $newcount = "$date||$count";
        fwrite($fil, $newcount); 

echo $date."<br>";
echo $count."<br>";
And, it always comes back where:

$date = Correct
$count = 1



Thanks for any help you can give me...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

list ($date, $count) = split('\|\|', $dat);
didn't know there is a special meaning to escape from for || in a string literal either, but obviously there is ;)
traffic
Forum Newbie
Posts: 17
Joined: Fri May 23, 2003 1:18 pm

Post by traffic »

Thank you...

I tried that.. however, it seems as if 'split' only works with slash, dot, or hyphen...

I wound up using:

Code: Select all

list ($date, $count) = preg_split ('/\|\|/', $dat);

Which worked great...



Thanks again...
Post Reply