'Convert PHP array values from string to integer [duplicate]
I am new to PHP. I used curl and regex to get all the number with a certain pattern from an HTML table like this:
preg_match_all("/<td>[0-9]{1,2}\.[0-9]{2}<\/td>/m",$result,$match);
print_r($match);
This is the result array: ($match)
Array ( [0] => Array ( [0] => 10.00 [1] => 10.00 [2] => 10.00 [3] => 1.00 [4] => 12.00 ) )
All the values are strings, I need them as integers. How to do that? I tried this solution, but it gives 0 as an integer (was 10.00). Is it because it's an array inside array?
$test = $match[0][1];
$test2 = (int)$test;
echo $test2
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
