Page 1 of 1

Split

Posted: Fri May 23, 2003 1:18 pm
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...

Posted: Fri May 23, 2003 2:45 pm
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 ;)

Posted: Fri May 23, 2003 5:00 pm
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...