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. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Stephan Schmidt <schst@php.net>                             |
  17. // |          Aidan Lister <aidan@php.net>                                |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: array_change_key_case.php,v 1.5 2004/06/12 06:53:00 aidan Exp $
  21. //
  22.  
  23.  
  24. if(!defined('CASE_LOWER')) {
  25.     define('CASE_LOWER'0);
  26. }
  27.  
  28. if(!defined('CASE_UPPER')) {
  29.     define('CASE_UPPER'1);
  30. }
  31.  
  32. /**
  33.  * Replace array_change_key_case()
  34.  *
  35.  * @category    PHP
  36.  * @package     PHP_Compat
  37.  * @link        http://php.net/function.array_change_key_case
  38.  * @author      Stephan Schmidt <schst@php.net>
  39.  * @author      Aidan Lister <aidan@php.net>
  40.  * @version     $Revision: 1.5 $
  41.  * @since       PHP 4.2.0
  42.  */
  43. if (!function_exists('array_change_key_case'))
  44. {
  45.     function array_change_key_case ($input$case = CASE_LOWER)
  46.     {
  47.         if (!is_array($input)) {
  48.             trigger_error('array_change_key_case(): The argument should be an array'E_USER_WARNING);
  49.             return false;
  50.         }
  51.         
  52.         $output = array ();
  53.         $keys   array_keys($input);
  54.         $casefunc ($case == CASE_LOWER'strtolower' 'strtoupper';
  55.  
  56.         foreach ($keys as $key{
  57.             $output[$casefunc($key)$input[$key];
  58.         }
  59.  
  60.         return $output;
  61.     }
  62. }
  63. ?>

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