Hello,
I have several string values that I wish to extract specific info from. String manipulation has always been my shortfall 🙁
The string is in this format 5-104
What I want to do is extract the 5 and the 104 into 2 seperate fields and ignore the -
Any help much appreciated.
Just found the answer 🙂
$string = "5-104"; $split = explode("-", $string); $fld1 = $split[0]; $fld2 = $split[1];
Thanks anyway.
Or, given that
list($fld1, $fld2) = explode('-', $string);
. Or
sscanf('%d-%d',$fld1,$fld2);
The string format syntax in the latter case just says "digits, followed by a hyphen, followed by more digits".