PHP array magic trick and manipulations

  1. manipulating multidimensional array using array_map
  2. /**
    * Ilterate multidimensional array simplicity
    * @desc modify and manipulate or populate multidimensional array with simple tricks
    * @param array $arr
    * @param function $callback
    * @return Array
    **/
    function Map($arr, $callback)
    {
      if (!is_callable($callback)) {
        throw new Exception("Callback must be function", 1);
      }
    
      return array_map(function ($key, $val) use ($callback) {
        return call_user_func($callback, $key, $val);
      }, array_keys($arr), $arr);
    }
    

Comments

Popular posts from this blog

Find Backlink From Google Dork

List of weapon buff materials, effects and how it can be durango wild lands

Install deb package via Termux