extract numeric values from string
-
How to extract Numeric values from String plz help
-
How to extract Numeric values from String plz help
not sure if you mean you have a string with a number in it and need to pull just the string or if you have a number returned as a string. but for the first you can separate the string using explode and then looping through the returned array and checking for is_numeric returning true and extracting that. the second should be able to be used directly $a = '1'; $echo 1 + $a; but if there is a issue with it, you can use an explicit cast like in C (int)$a for example.
-
How to extract Numeric values from String plz help
In the PHP documentation of Strings[^] there is a little snippet just over a third of the way down called "String conversion to numbers", which may help you. Other than that, you could always go through the string char by char ;P
If at first you don't succeed, you're not Chuck Norris.
-
How to extract Numeric values from String plz help
I know this is a few days old but I thought I'd mention some new functionality in PHP. PHP Filters. Specifically:
<?php
$value01 = '123abc456def';
echo filter_var($value01, FILTER_SANITIZE_NUMBER_INT);
?>Will Output:
123456
-
I know this is a few days old but I thought I'd mention some new functionality in PHP. PHP Filters. Specifically:
<?php
$value01 = '123abc456def';
echo filter_var($value01, FILTER_SANITIZE_NUMBER_INT);
?>Will Output:
123456
-
That's very useful. Bookmarked this for future reference, just in case.
If at first you don't succeed, you're not Chuck Norris.
Yeah. Good tut here[^].