Answers for "php get value of multidimensional array"

PHP
1

php multidimensional array get all values by key

$ids = array_column($users, 'id');
Posted by: Guest on May-04-2021
0

get the matched value from 2 multidimensional array in php by id

<?php
  $a = Array(
      Array('id' => 1, 'affiliate_id' => 190),
      Array('id' => 2, 'affiliate_id' => 946)
  );

  $b = Array(
      Array('id' => 1, 'user_id' => 190),
      Array('id' => 2, 'user_id' => 246),
      Array('id' => 3, 'user_id' => 249),
      Array('id' => 3, 'user_id' => 250)
  );

  $c = array_map(function ($arr) { return $arr['affiliate_id']; }, $a);
  $d = array_map(function ($arr) { return $arr['user_id']; }, $b);

  $e = array_intersect($c, $d);

  // Output
  // Array ( [0] => 190 )

?>
Posted by: Guest on August-18-2021

Code answers related to "php get value of multidimensional array"

Browse Popular Code Answers by Language