Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

strrev

(PHP 3, PHP 4, PHP 5)

strrev -- Переворачивает строку

Description

string strrev ( string string )

Возвращает строку string, в которой порядок символов изменен на обратный.

Пример 1. Пример использования strrev()

<?php
echo strrev("Hello world!"); // выводит "!dlrow olleH"
?>



strripos> <strrchr
Last updated: Sat, 27 Jan 2007
 
add a note add a note User Contributed Notes
strrev
carmel.alex at gmail.com
20-Dec-2006 10:38
to lwc at mytrashmail dot com,  take it easy.

function utf8_strrev($str, $reverse_numbers = true){
    $pattern = $reverse_numbers ? '/./us' : '/(\d+)?./us';
    preg_match_all($pattern, $str, $ar);
    return join('',array_reverse($ar[0]));
}
lwc at mytrashmail dot com
13-Oct-2006 04:01
just as well for UTF-8 usages = I meant also for NONE UTF-8 usages (to keep the numbers unchanged)
lwc at mytrashmail dot com
13-Oct-2006 01:35
/*
Here's a function that adds to carmel.alex's utf-8 encoding support the ability NOT to reverse numbers (for example when you output a phrase as a parameter for a SWF file that can't handle RTL languages itself, but obviously any numbers should remain the same as in the original phrase).

Note that it can be used just as well for UTF-8 usages if you want the numbers to remain intact:
*/

function utf8_strrev($str, $reverse_numbers) {
  preg_match_all('/./us', $str, $ar);
  if ($reverse_numbers)
    return join('',array_reverse($ar[0]));
  else {
      $temp = array();
      foreach ($ar[0] as $value) {
         if (is_numeric($value) && !empty($temp[0]) && is_numeric($temp[0])) {
            foreach ($temp as $key => $value2) {
               if (is_numeric($value2))
                 $pos = ($key + 1);
               else
                  break;
            }
            $temp2 = array_splice($temp, $pos);
            $temp = array_merge($temp, array($value), $temp2);
         } else
            array_unshift($temp, $value);
      }
      return implode('', $temp);
  }
}

// "It says this site is copyrighted just from 2001" (in Hebrew)
$str = "
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571