This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$colors = array("0"=>"Red","1"=>"Green","2"=>"Blue"); | |
echo "0th element of array is " . $colors["0"]; | |
echo "<br>"; | |
//looping | |
foreach ($colors as $key=>$value){ | |
echo "Key=".$key." value=".$value; | |
echo "<br>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fruits = array('apple', 'mango', 'grape', 'orange'); | |
echo 'Do While Loop Example <br>'; | |
$i = 0; | |
do{ | |
echo ('I am '.$fruits[$i].'.<br>'); | |
$i++; | |
}while( $i < count($fruits) ) | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$operating_system = array("Windows", "Linux", "Mac"); | |
echo count($operating_system); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$books = array( | |
array( | |
"title" => "The C Programming Language", | |
"author" => "Brian Kernighan and Dennis Ritchie", | |
"available" => 19 | |
), | |
array( | |
"title" => "Learning Python", | |
"author" => "David Ascher and Mark Lutz", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// associative array examples | |
$cart = array( 'Hotel' => 95, 'Chicken65' => 'Restaurant', 45 => 'xyz' ); | |
// or | |
$list = [ | |
'Hotel' => 95, | |
'Chicken65' => 'Restaurant', | |
45 => 'xyz' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// indexed array examples | |
$list = array( 'mango', 'apple', 'grape', 'orange' ); | |
// or | |
$list = [ 'mango', 'apple', 'grape', 'orange' ]; | |
//or | |
$list = array(); |
NewerOlder