Here's my string: "N/A - -0.09%" (the double quotes are included and part of the string I want to dissect)
Here's my code:
$url = 'abc123.php';
$data = file_get_contents($url); //$data contains "N/A - -0.09%" (the string to parse)
$regex = '/""/';
preg_match($regex,$data,$match);
var_dump($match);
How do I isolate everything after the first hyphen, but before the % sign?
I know for a fact that the string will ALWAYS have " "N/A - " in front, and I only want to extract the number with its negative sign if it's negative.
I want to assign the number -0.09 to a variable. The number may be positive or negative. If it's positive there will be no hypen, eg. 0.123. If it's negative there will be a second hyphen in addition to the first, eg. -2.5 .
Please help me formulate the regex part to isolate -0.09 into a variable, say $number. THANK YOU SO!