Re: Help in tokenizing a string

From: Date: Fri, 01 Feb 2002 09:51:07 +0000
Subject: Re: Help in tokenizing a string
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-16391@lists.php.net to get a copy of this message
I'm not sure why that isn't working, but this might do what you want: $index = strrpos($im_file, "\\"); $im = substr($im_file, $index + 1, strlen($im_file)); I just tested it out here and that works fine, $im = "image.jpg" On February 1, 2002 02:41 am, you wrote: > Good day to all. > > I tried the following code from PHP's manual > > if (isset($submit)) > { > if ($submit == "Save") > { > echo "$im_file<BR>"; > $tok = strtok($im_file, "\\"); > while ($tok) > { > echo "$tok<BR>"; > $tok = strtok ("\\"); > } > } > } > > I have the string $im_file ="C:\\<a_path>\\image.jpg" and I want to have > into a variable (say it $im) just the filename part (image.jpg). > The code above, returns me just a "C:" :(( > > Any suggestions greatly appreciated. -- Dave Sullivan Web: http://asliver.ath.cx/

« previous php.db (#16391) next »