Source for file reverse.php

Documentation is available at reverse.php

  1. <?php
  2.  
  3. /**
  4.  * Reverses a string or an array
  5.  * <pre>
  6.  *  * value : the string or array to reverse
  7.  *  * preserve_keys : if value is an array and this is true, then the array keys are left intact
  8.  * </pre>
  9.  * This software is provided 'as-is', without any express or implied warranty.
  10.  * In no event will the authors be held liable for any damages arising from the use of this software.
  11.  *
  12.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  13.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  14.  * @license    http://dwoo.org/LICENSE   Modified BSD License
  15.  * @link       http://dwoo.org/
  16.  * @version    1.0.0
  17.  * @date       2008-10-23
  18.  * @package    Dwoo
  19.  */
  20. function Dwoo_Plugin_reverse(Dwoo $dwoo$value$preserve_keys=false)
  21. {
  22.     if (is_array($value)) {
  23.         return array_reverse($value$preserve_keys);
  24.     elseif(($charset=$dwoo->getCharset()) === 'iso-8859-1'{
  25.         return strrev((string) $value);
  26.     else {
  27.         $strlen mb_strlen($value);
  28.         $out '';
  29.         while ($strlen--{
  30.             $out .= mb_substr($value$strlen1$charset);
  31.         }
  32.         return $out;
  33.     }
  34. }

Documentation generated on Sun, 07 Feb 2010 17:53:55 +0000 by phpDocumentor 1.4.0