Buy Now
Sign in

how to convert variable from string to number

lf14web , June 14 at 19:30
Answered
L
lf14web
Hi,​
​The result of this query I get a number: 11325​
​​
​I can not to do a operation mathematic with this number because the system read this value how a string.​
​​
​I tried to convert this variable to number whitout success and I obtaim always 0:
<?php​
​​
​$num='{var:read_data26}';​
​//$dtc -= 7;​
​$int = (int)$num;​
​$float = (float)$num;​
​$intval = intval($num);​
​​
​echo $num."///" ;​
​echo $intval."///" ;​
​echo $int."///" ;​
​echo $float ;​
​​
​?>
Result:
11325///0///0///0
How I can to use this data how number?
Thanks
Emanuele
Array
(
[_ga] => GA1.2.371091234.1528460153
[adcf749bbd5f64903947be2e21155320] => 6tl20k36bpmc4fnaml0sijl312
[78f1bfe75faa4fc86eec21112d3f6c0e] => uqrvdq3qi8uunm4v8ooabui7i7
[Itemid] => 117
[option] => com_chronoforms6
[view] => form
)
Array
(
[read_data26] => Array
(
[log] => Array
(
[0] => SELECT COUNT(`contatabella`.`aid`) AS `contatabella.count` FROM `u53uf_chronoforms_data_rilievi-idrometrici-laghi` AS `contatabella` LIMIT 100;
)

[var] => 11325
)

)
GreyHead
Hi If14web,
Please try removing the quotes from the first line:
$num = {var:read_data26};
Bob
Later: Sorry, this is not correct - please see healyhatman's later post.
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
L
lf14web
Hi Bob,
I've already tried, but doesn't work.
:-(
H
healyhatman
You can't use a shortcode in php code. Replace it with $num = $this->get("read_data26", "");
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman