...

View Full Version : correct way to split a string (need number before &) eg: 12&image.png



fatrat
01-08-2007, 09:27 PM
hi,

i have a string

$str =12&image.png

how do i get everything before the '&'

the number of characters before the '&' is unknown.

it can be 0, but not null.

possible examples:

$str = 0&blank.png
$str = 2&hi.png
$str = 3&black.png


[edit]

how about this:


$user_flag = substr($user_flag, 0, strpos($user_flag, '&') );

GJay
01-08-2007, 09:46 PM
$user_flag=current(explode('&',$user_flag));

is a bit shorter

fatrat
01-09-2007, 01:38 AM
thanks for that, updating now ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum