Home >Backend Development >PHP Tutorial >PHP gets the reverse order of a string according to the requirements_PHP tutorial

PHP gets the reverse order of a string according to the requirements_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:53:351005browse

php gets the reverse order of the string according to the requirements

/**
* Get the reverse order of the string according to the requirements
*/

$s = 'abcdefghijklmnopq';
function Reverse_order($str,$start = null,$end = null)
{

$string = '';
$string1 = '';
$string2 = '';
if ($start === null or $end == = null)
{
for ($i = 0; ($char = $str{$i}) !== '';$i++)
{
$string = $char. $string;
}
          //var_dump($string);
                                                                                                                                                             $end !== null) //Convert the user input as a numeric string into an integer
{
//If it is a letter or Chinese character, $start $end will be 0
after conversion $start = ( int)($start);
                                                                                                                                                                   ,,,, 256);
                 return false; " :) ''; $k++)
                                                                                                                                                                                                                                                                        end))
{
trigger_error("Please enter a number",512);
return false;
}*/
return $string1.$string.$string2;
}
$start = 0;
var_dump(
Reverse_order($s,$start,10),
Reverse_order($s,5,15),
Reverse_order($s,'10 ','15'),
//Reverse_order($s,'-5','15'), //A negative string is converted into a negative number
Reverse_order($s,'df', 'sd'),
Reverse_order($s,'','place'), //When strings that are not numbers are converted to integers, they are all zero
Reverse_order($s)
);

Author: k7gxn56




http://www.bkjia.com/PHPjc/364728.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/364728.html

TechArticle

php Get the reverse order of the string as required?php /*** Get the reverse order of the string as required*/ $s = 'abcdefghijklmnopq '; function Reverse_order($str,$start = null,$end = null) { $stri...



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn