src/Borla/Chikka/Support/Utilities.php
static function arrayExtract(array $keys, array $array, array $callbacks = []) {
    // Set extracted
    $extracted = [];
    // Loop through keys
    foreach ($keys as $key) {
      // Add to extracted, only if it exists
      if (array_key_exists($key, $array)) {
        // Set item
        $item = $array[$key];
        // If there's a callback
        if (isset($callbacks[$key]) && is_callable($callbacks[$key])) {
          // Call it
          $item = call_user_func_array($callbacks[$key], [$item]);
        }
        // Add to extracted
        $extracted[$key] = $item;
      }
    }
    // Return extracted
    return $extracted;
  }
static function arrayExtract(array $keys, array $array, array $callbacks = []) {
    // Set extracted
    $extracted = [];
    // Loop through keys
    foreach ($keys as $key) {
      // Add to extracted, only if it exists
      if (array_key_exists($key, $array)) {
        // Set item
        $item = $array[$key];
        // If there's a callback
        if (isset($callbacks[$key]) && is_callable($callbacks[$key])) {
          // Call it
          $item = call_user_func_array($callbacks[$key], [$item]);
        }
        // Add to extracted
        $extracted[$key] = $item;
      }
    }
    // Return extracted
    return $extracted;
  }
static function arrayExtract ( array $ keys , array $ array , array $ callbacks = [ ] ) { // Set extracted $ extracted = [ ] ; // Loop through keys foreach ( $ keys as $ key ) { // Add to extracted, only if it exists if ( array_key_exists ( $ key , $ array ) ) { // Set item $ item = $ array [ $ key ] ; // If there's a callback if ( isset ( $ callbacks [ $ key ] ) && is_callable ( $ callbacks [ $ key ] ) ) { // Call it $ item = call_user_func_array ( $ callbacks [ $ key ] , [ $ item ] ) ; } // Add to extracted $ extracted [ $ key ] = $ item ; } } // Return extracted return $ extracted ; }
Extract array from array with keys
Extract array from array with keys