Array is a function, which stores one or more data at a time.
Example:
<?php
$game=array("chess","cricket","Kabadi");
echo "I like " . $game[0] . "game" ;
?>
$game=array("chess","cricket","Kabadi");
echo "I like " . $game[0] . "game" ;
?>
Array using loop
<?php
$game=array("chess","cricket","Kabadi");
$alen=count($game);
for($i=0;$i<$alen;$i++)
{
echo $game[$i];
$game=array("chess","cricket","Kabadi");
$alen=count($game);
for($i=0;$i<$alen;$i++)
{
echo $game[$i];
echo "<br>"; // if u want next line use this
}
?>
}
?>
Output:
chess
cricket
Kabadi
Sorting
Example:
<?php
$int=array(2,6,9,7,1,4);
sort($int . " ");
?>
$int=array(2,6,9,7,1,4);
sort($int . " ");
?>
Output:
1 2 4 6 7 9
Find Count
Example:
<?php
$int=array(2,6,9,7,1,4);
count($int");
?>
$int=array(2,6,9,7,1,4);
count($int");
?>
output:
6
How to search data in array
Example:
<?php
$find = array("java", "dotnet", "php");
if (in_array("dotnet", $find))
{
echo "MS dotnet";
}
else
{
echo "Not Found";
}
?>
Output:MS dotnet
How to find string length
Example:
<?php echo "GK DevelopmentS"; ?>Output:
15
No comments:
Post a Comment