自己寫的相容低於PHP 5.5版本的array_column()函數,5.5array_column_PHP教程

來源:互聯網
上載者:User

自己寫的相容低於PHP 5.5版本的array_column()函數,5.5array_column


array_column 用於擷取二維數組中的元素(PHP 5.5新增函數),但我們有時候需要在低版本的PHP環境中使用…

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;  }}

目前apache最新版本是?可以相容php536與mysql 55117

下面是個在網上找的安裝步驟,具體我也沒再apache下配置過,
如果不想麻煩可以下個現成的組件,比如PHPnow,整合了apache+php+mysql+Zend Optimizer+eAccelerator需要配置的都整合好了,安裝一下就成啦
當然是2003下好啦

 

cms系統怎做到對各個版本php(40或者50)伺服器的相容?

要做到既可以在php4上運行,又可以在php5上運行,你需要有一個版本判斷的功能

你可以這樣:
if (version_compare( phpversion(), '5', '<' ) )
include_once( 'php4.php' ) ;//php4的相關設定檔或調用函數
else
include_once( 'php5.php' ) ;//php5的相關檔案或調用函數
}
這樣在不同的環境下,就可以調用不同的檔案,實現你的功能,不過具體要實現要複雜的多。
希望對你有協助
 

http://www.bkjia.com/PHPjc/899062.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/899062.htmlTechArticle自己寫的相容低於PHP 5.5版本的array_column()函數,5.5array_column array_column 用於擷取二維數組中的元素(PHP 5.5新增函數),但我們有時候需要在低...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.