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

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