fork download
  1. <?php
  2.  
  3. $variable = [
  4. "0" => [
  5. "category_name" => 'Coffee Machines',
  6. "categoryId" => 12,
  7. "animateTitle" => 'Better ways to cleaner dishes.',
  8. "animateIcon" => '',
  9. "animateLink" => 'http://google.com',
  10. "animateBG" => "",
  11. "fram1" => [
  12. "ID" => 315,
  13. "id" => 315,
  14. "title" => 'coffee-frame1',
  15. "filename" => 'coffee-frame1.png',
  16. ],
  17. "fram2" => [
  18. "ID" => 316,
  19. "id" => 316,
  20. "title" => 'coffee-frame2',
  21. "filename" => 'coffee-frame2.png',
  22. ]
  23. ],
  24. "1" => [
  25. "category_name" => 'Cooking & Baking',
  26. "categoryId" => 13,
  27. "animateTitle" => 'Better ways to cleaner dishes.',
  28. "animateIcon" => '',
  29. "animateLink" => 'http://google.com',
  30. "animateBG" => '',
  31. "fram1" => [
  32. "ID" => 318,
  33. "id" => 318,
  34. "title" => 'cookie-frame1',
  35. "filename" => 'cookie-frame1.png',
  36. ],
  37. "fram2" => [
  38. "ID" => 319,
  39. "id" => 319,
  40. "title" => 'cookie-frame2',
  41. "filename" => 'cookie-frame2.png',
  42. ]
  43. ]
  44. ];
  45.  
  46. $result = array_filter($variable, function($item) {
  47. return $item['categoryId'] == 13;
  48. });
  49.  
  50. print_r($result);
Success #stdin #stdout 0.03s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [1] => Array
        (
            [category_name] => Cooking & Baking
            [categoryId] => 13
            [animateTitle] => Better ways to cleaner dishes.
            [animateIcon] => 
            [animateLink] => http://google.com
            [animateBG] => 
            [fram1] => Array
                (
                    [ID] => 318
                    [id] => 318
                    [title] => cookie-frame1
                    [filename] => cookie-frame1.png
                )

            [fram2] => Array
                (
                    [ID] => 319
                    [id] => 319
                    [title] => cookie-frame2
                    [filename] => cookie-frame2.png
                )

        )

)