PHP Classes

File: examples/example2.php

Recommend this page to a friend!
  Classes of Jorge Castro   PHP Array One   examples/example2.php   Download  
File: examples/example2.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Array One
Perform several types of operations on arrays
Author: By
Last change:
Date: 1 year ago
Size: 1,331 bytes
 

Contents

Class file image Download
<?php

$top
= [
   
"id" => "0001",
   
"type" => "donut",
   
"name" => "Cake",
   
"ppu" => 0.55,
   
"batters" => [
       
"batter" => [
            [
               
"id" => "1001",
               
"type" => "Regular"
           
],
            [
               
"id" => "1002",
               
"type" => "Chocolate"
           
],
            [
               
"id" => "1003",
               
"type" => "Blueberry"
           
],
            [
               
"id" => "1004",
               
"type" => "Devil's Food"
           
]
        ]
    ],
   
"topping" => [
        [
           
"id" => "5001",
           
"type" => "None"
       
],
        [
           
"id" => "5002",
           
"type" => "Glazed"
       
],
        [
           
"id" => "5005",
           
"type" => "Sugar"
       
],
        [
           
"id" => "5007",
           
"type" => "Powdered Sugar"
       
],
        [
           
"id" => "5006",
           
"type" => "Chocolate with Sprinkles"
       
],
        [
           
"id" => "5003",
           
"type" => "Chocolate"
       
],
        [
           
"id" => "5004",
           
"type" => "Maple"
       
]
    ]
];

use
eftec\ArrayOne;

include
__DIR__.'/../vendor/autoload.php';
$result=ArrayOne::set($top)->nav('topping')->reduce(['id'=>'count'])->current();
var_dump($result);