strval() to get string from a variable

From any type of data ( variable ) we can get string output. This can be used to convert any numeric data to string.
echo strval(34)."<br>"; //34
echo strval(12.34)."<br>"; // 12.34 
echo strval(12.340)."<br>"; // 12.34 
echo strval(.34)."<br>"; // 0.34 
echo strval(0.34)."<br>"; // 0.34 
echo strval(-0.34)."<br>"; // -0.34 
echo strval('plus2net')."<br>";// plus2net
The return value is string.

Application using strval()

Find the sum of every 2nd digit of any integer.
for($i=0; $i<strlen($my_num); $i++){
	if(($i % 2) ==0){
	$sum=$sum + $my_num[$i];	
Output is 16
Declaring variables Cookies to store Infomation Getting Type of Variable var_dump() empty()
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer