Compatible with array_column () functions earlier than PHP5.5, 5.5array _ column_PHP tutorial

Source: Internet
Author: User
Compatible with array_column () functions earlier than PHP5.5, 5.5array _ column. The array_column () function is compatible with earlier than PHP5.5, and 5.5array _ columnarray_column is used to obtain elements in a two-dimensional array (new function in PHP5.5 ), but sometimes we need to write the array_column () function that is less compatible with PHP 5.5, 5.5array _ column

Array_column is used to obtain elements in a two-dimensional array (new functions in PHP 5.5), but sometimes we need to use them in a lower version of PHP environment...

if( ! function_exists('array_column')){  function array_column($input, $columnKey, $indexKey = NULL)  {    $columnKeyIsNumber = (is_numeric($columnKey)) ? TRUE : FALSE;    $indexKeyIsNull = (is_null($indexKey)) ? TRUE : FALSE;    $indexKeyIsNumber = (is_numeric($indexKey)) ? TRUE : FALSE;    $result = array();    foreach ((array)$input AS $key => $row)    {       if ($columnKeyIsNumber)      {        $tmp = array_slice($row, $columnKey, 1);        $tmp = (is_array($tmp) && !empty($tmp)) ? current($tmp) : NULL;      }      else      {        $tmp = isset($row[$columnKey]) ? $row[$columnKey] : NULL;      }      if ( ! $indexKeyIsNull)      {        if ($indexKeyIsNumber)        {          $key = array_slice($row, $indexKey, 1);          $key = (is_array($key) && ! empty($key)) ? current($key) : NULL;          $key = is_null($key) ? 0 : $key;        }        else        {          $key = isset($row[$indexKey]) ? $row[$indexKey] : 0;        }      }      $result[$key] = $tmp;    }    return $result;  }}


What is the latest apache version? Compatible with php536 and mysql 55117

The following is an installation procedure on the internet. I have not configured it in apache,
If you don't want to bother, you can use the next ready-made component, such as PHPnow, which integrates apache + php + mysql + Zend Optimizer + eAccelerator. you have integrated all the configurations you need. just install it.
Of course it's 2003.


How can the cms system be compatible with php (40 or 50) servers of various versions?

To run both on php4 and php5, you need a version judgment function.

You can:
If (version_compare (phpversion (), '5', '<'))
Include_once ('php4. php'); // related configuration file or call function of php4
Else
Include_once ('php5. php'); // php5 related files or call functions
}
In this way, you can call different files in different environments to implement your functions. However, the specific implementation is much more complicated.
Hope to help you

The array_column () function of version 5.5, 5.5array _ column array_column, is used to obtain elements in a two-dimensional array (new function in PHP 5.5), but sometimes we need to be at a low level...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.