How do I force a value to be treated as a number?
Here's an example:
<?php
$value = (int) "25atoz";
$multiple = $value * $value;
echo "$multiple";
?>
This will print '625' to the screen. Using the word (int) ensures PHP creates an integer variable with a value of '25' - otherwise it would create a string variable.
Comment on this Question and Answer >>>
ASK A QUESTION
More numbers PHP Questions
percentage QuestionsHow do I round up a number?
How do I format a number with commas like a monetary value?
I got a weird problem on float number. I stored an integer number into an array like $number[$i]['duration']= 9 ,and return this array to main function. Then I need to do some calculation in main function with this number like: 1.$temp=0.5 2.var_du
How do I work out the remainder of a division?
