Write your own array_column () function that is less than PHP 5.5, 5.5array_column_php Tutorial

Source: Internet
Author: User

Write your own array_column () function that is less than PHP 5.5, 5.5array_column


Array_column is used to get elements from a two-dimensional array (PHP 5.5 new), but we sometimes need to use it in a low-version PHP environment ...

if (! function_exists (' Array_column ')) {function Array_column ($input, $columnKey, $indexKey = NULL) {$columnKeyIsNum ber = (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, $colu        Mnkey, 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 current Apache version? can be compatible with php536 and MySQL 55117

Below is an online look for installation procedures, specifically I have not been configured under Apache,
If you do not want trouble can be the next ready-made components, such as Phpnow, integrated apache+php+mysql+zend optimizer+eaccelerator need to be configured to integrate all, install it.
2003, of course.


How is CMS system compatible with each version of PHP (40 or 50) servers?

To be able to run both on PHP4 and on php5, you need to have a version-judged function

You can do this:
if (Version_compare (Phpversion (), ' 5 ', ' < '))
Include_once (' php4.php ');//php4 related configuration file or calling function
Else
Include_once (' php5.php ');//php5 related file or call function
}
This way, in different environments, you can invoke different files to implement your functionality, but the specifics are much more complex to implement.
Hope to help you

http://www.bkjia.com/PHPjc/899062.html www.bkjia.com true http://www.bkjia.com/PHPjc/899062.html techarticle Write your own array_column () function that is less than PHP 5.5, 5.5array_column array_column is used to get the elements in a two-dimensional array (PHP 5.5 new function), but we sometimes need to be in the low ...

  • 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.