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(); |
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 | |
$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 | |
$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 | |
$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 | |
$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 | |
//Indexed two-dimensional array | |
$cars = array( | |
array("Honda Accord", "V6", 30000), | |
array("Toyota Camry", "LE", 24000), | |
array("Nissan Altima", "V1", 10000), | |
); | |
foreach($cars as $car){ |
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 | |
namespace App\Http\Controllers; | |
use DB; | |
use Config; | |
use App\Models\Course; | |
use Illuminate\Http\Request; | |
use Yajra\Datatables\Datatables; | |
use Illuminate\Support\Facades\Validator; |
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 | |
// -- Only one caveat : The results must be ordered so that an item's parent will be processed first. | |
// -- Simulate a DB result | |
$results = array(); | |
$results[] = array('id' => 'a', 'parent' => '', 'name' => 'Johnny'); | |
$results[] = array('id' => 'b', 'parent' => 'a', 'name' => 'Bobby'); | |
$results[] = array('id' => 'c', 'parent' => 'b', 'name' => 'Marky'); | |
$results[] = array('id' => 'd', 'parent' => 'a', 'name' => 'Ricky'); |
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
{ | |
"states": [ | |
{ | |
"id": "1", | |
"type": "Union Territory", | |
"capital": "Mayabunder", | |
"code": "AN", | |
"name": "Andaman and Nicobar Islands", | |
"districts": [ | |
{ |
OlderNewer