Skip to content

Instantly share code, notes, and snippets.

View MubinSayed's full-sized avatar
🎯
Focusing

Mubin Sayed MubinSayed

🎯
Focusing
View GitHub Profile
@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();
<?php
// associative array examples
$cart = array( 'Hotel' => 95, 'Chicken65' => 'Restaurant', 45 => 'xyz' );
// or
$list = [
'Hotel' => 95,
'Chicken65' => 'Restaurant',
45 => 'xyz'
<?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
$operating_system = array("Windows", "Linux", "Mac");
echo count($operating_system);
?>
<?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
$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
//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){
@MubinSayed
MubinSayed / CourseController.php
Last active April 25, 2021 05:11
Laravel Datatable Dynamic Filter (Advance Filter) (phpMyAdmin Style)
<?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;
@MubinSayed
MubinSayed / covertToHierarchy.php
Created April 12, 2019 12:32 — forked from ubermaniac/covertToHierarchy.php
Convert a DB result of parent/child items into a hierarchical array
<?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');
@MubinSayed
MubinSayed / IndianStatesDistricts.json
Created March 28, 2021 08:52 — forked from Dhaneshmonds/IndianStatesDistricts.json
Indian states, capitals and districts
{
"states": [
{
"id": "1",
"type": "Union Territory",
"capital": "Mayabunder",
"code": "AN",
"name": "Andaman and Nicobar Islands",
"districts": [
{