Handling integer types

Just to give you an idea of the problem before I show you the solution, here's why this is posted here.

I had a script that read an xml file with simplexml and then output the value of the tag based on a number passed in a query string attached to the url. I had to print the message using the following line

print($xml_parsed->msg[$number]);

This did not work, because it did not think $number was an integer value so that we could reference the value from the array $xml_parsed->msg. In order to tell PHP that $number is an integer, or at least a number, you can run the following function on $number.

$number = intval($alert_number);

http://docs.php.net/intval »

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.