PHP_Compat
[ class tree: PHP_Compat ] [ index: PHP_Compat ] [ all elements ]

Source for file array_change_key_case.php

Documentation is available at array_change_key_case.php

  1. <?php
  2. if (!defined('CASE_LOWER')) {
  3.     define('CASE_LOWER'0);
  4. }
  5.  
  6. if (!defined('CASE_UPPER')) {
  7.     define('CASE_UPPER'1);
  8. }
  9.  
  10.  
  11. /**
  12.  * Replace array_change_key_case()
  13.  *
  14.  * @category    PHP
  15.  * @package     PHP_Compat
  16.  * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
  17.  * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
  18.  * @link        http://php.net/function.array_change_key_case
  19.  * @author      Stephan Schmidt <schst@php.net>
  20.  * @author      Aidan Lister <aidan@php.net>
  21.  * @version     $Revision: 269597 $
  22.  * @since       PHP 4.2.0
  23.  * @require     PHP 4.0.0 (user_error)
  24.  */
  25. function php_compat_array_change_key_case($input$case = CASE_LOWER)
  26. {
  27.     if (!is_array($input)) {
  28.         user_error('array_change_key_case(): The argument should be an array',
  29.             E_USER_WARNING);
  30.         return false;
  31.     }
  32.  
  33.     $output   = array ();
  34.     $keys     array_keys($input);
  35.     $casefunc ($case == CASE_LOWER'strtolower' 'strtoupper';
  36.  
  37.     foreach ($keys as $key{
  38.         $output[$casefunc($key)$input[$key];
  39.     }
  40.  
  41.     return $output;
  42. }
  43.  
  44.  
  45. // Define
  46. if (!function_exists('array_change_key_case')) {
  47.     function array_change_key_case($input$case = CASE_LOWER)
  48.     {
  49.         return php_compat_array_change_key_case($input$case);
  50.     }
  51. }

Documentation generated on Mon, 11 Mar 2019 15:39:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.