Skip to content

Instantly share code, notes, and snippets.

View MubinSayed's full-sized avatar
🎯
Focusing

Mubin Sayed MubinSayed

🎯
Focusing
View GitHub Profile
<?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>";
<?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) )
?>
<?php
$operating_system = array("Windows", "Linux", "Mac");
echo count($operating_system);
?>
<?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",
<?php
// associative array examples
$cart = array( 'Hotel' => 95, 'Chicken65' => 'Restaurant', 45 => 'xyz' );
// or
$list = [
'Hotel' => 95,
'Chicken65' => 'Restaurant',
45 => 'xyz'
@MubinSayed
MubinSayed / indexed.php
Last active September 25, 2018 03:39
php arrays
<?php
// indexed array examples
$list = array( 'mango', 'apple', 'grape', 'orange' );
// or
$list = [ 'mango', 'apple', 'grape', 'orange' ];
//or
$list = array();