So I outputed a result from {{blogs.totalPage}}
.This {{blogs.totalPage}}
has a value of 5
. Then this value, I added it to my while loop. But the while loop is not working and the ouput is 0
because the outputed value 5 is String not Int.
<?php
$cnt = 0;
$pageTotal = "'{{blogs.totalPage}}'";
while($cnt<=$pageTotal){
echo "Number: ".$cnt
$cnt++;
}
Then I tried adding (int)
<?php
$cnt = 0;
$pageTotal = (int)"'{{blogs.totalPage}}'";
while($cnt<=$pageTotal){
echo "Number: ".$cnt
$cnt++;
}
Can you help me to convert this String into Int to make my while loop working? Thanks
Let me add, the reason why I know it is string and has an output of 5, I tried to var_dump($pageTotal)
and the output is string(21) "'5'"