Professional Documents
Culture Documents
Msbtebook.blogspot.com
6.print the Fibonacci series up to n numbers.
<?php
$no=5;
$no1=0;
$no2=1;
$no3=0;
echo $no1;
echo $no2;
for($i=1;$i<$no;$i++)
{
$no3=$no1+$no2;
echo $no3;
$no1=$no2;
$no2=$no3;
}
?>
7.write a program which reverse the given number.
<?php
$no=18;
strval($no);
print("reverse of $no"."=".strrev($no));
?>
Msbtebook.blogspot.com
}
?>
17. find the index of particular character from string(Last occurenace).
<?php
$str="AKASH";
$ch="A";
$i=strlen($str);
while($i>=0)
{
if($str[$i]==$ch)
{
echo "Index of $ch"."=".$i;
break;
}
$i--;
}
?>
Msbtebook.blogspot.com
18. convert the string into uppercase to lowercase without using method.
<?php
$str="AKASH";
$i=0;
$lowerstring="";
$length=strlen($str);
while($i<$length)
{
if(ord($str[$i])>=65 && ord($str[$i])<=90)
{
$lowerstring.="".chr(ord($str[$i])+32);
}
$i++;
}
echo "lowercase string=".$lowerstring;
?>
18. convert the string into lowercase to uppercase without using method.
<?php
$str="akash";
$i=0;
$upperstring="";
$length=strlen($str);
while($i<$length)
{
if(ord($str[$i])>=97 && ord($str[$i])<=122)
{
$upperstring.="".chr(ord($str[$i])-32);
}
$i++;
}
echo "upercase string=".$upperstring;
?>
Msbtebook.blogspot.com
MSBTE CAMPUS
PHP IMP QUESTIONS