Answers for "Hash::extract"

PHP
1

Hash::extract

// input
$data = Array(
    [0] => Array (
            [Product] => Array (
                    [id] => 5
                    [product_number] => RT001C
                ))
    [1] => Array (
            [Product] => Array  (
                    [id] => 7
                    [product_number] => RC001C 
                ))
);

$data = Hash::extract($data, '{n}.Product');
// => output
$data = Array(
  	[0]	=> Array (
      	[id] => 5
      	[product_number] => RT001C
    )
    [1] => Array (
     	[id] => 7
      	[product_number] => RC001C 
    )
);
Posted by: Guest on December-15-2020

Browse Popular Code Answers by Language