Determines whether the input string is a palindrome number

Source: Internet
Author: User

<?php
function Yuanyincount ($STR)
{
$str _len=strlen ($STR);

$a _count=0;
$e _count=0;
$i _count=0;
$o _count=0;
$u _count=0;
$other _count=0;

Array of five reason letters, no write output
$a _arr=array ();
$e _arr=array ();
$i _arr=array ();
$o _arr=array ();
$u _arr=array ();
$other _arr=array ();

$yuanyin _arr=array ();//inverse array
$temp = ";
for ($i =0; $i < $str _len; $i + +) {
$temp =substr ($str, $i, 1);//
$temp =strtolower ($temp);//Don't consider the case first
Switch ($temp) {
Case ' a ':
$a _count++;
$a _arr[]= $temp;
Break

Case ' E ':
$e _count++;
$e _arr[]= $temp;
Break

Case ' I ':
$i _count++;
$i _arr[]= $temp;
Break

Case ' O ':
$o _count++;
$i _arr[]= $temp;
Break

Case ' U ':
$u _count++;
$u _arr[]= $temp;
Break

Default
$other _count++;
$other _arr[]= $temp;
Break
}
}
The number of echoes ' vowel letters is ', $a _count+ $e _count+ $i _count+ $o _count+ $u _count, ' <br/> ';
The number of ECHO ' letters A is: ', $a _count, ' <br/> ';
The number of ECHO ' letter E is: ', $e _count, ' <br/> ';
The number of ECHO ' Letter B is: ', $i _count, ' <br/> ';
The number of echo ' O ' letters is: ', $o _count, ' <br/> ';
The number of echo ' Letters U is: ', $u _count, ' <br/> ';
}
function Getmicrotime ()
{
//
List ($usec, $sec) =explode (", Microtime ());
return (float) $usec + (float) $sec);
}
Record start time
$starttime =getmicrotime ();
echo yuanyincount (' Dfjkfdhjgjhfsdaoijiaoiaoko ');
Place the code to execute
For example Echo createpwd ();
Record End time
$endtime =getmicrotime ();
$time = $endtime-$starttime;
echo ' Execution time '. $time, ' <br/> ';

function Jutice_huiwen ($STR) {
Determines whether the input string is a palindrome
$str _rev=strrev ($STR);
if ($str = = = $str _rev) {
Echo $str, ' is a palindrome number ', ' <br/> ';
}else{
echo $str, ' not a palindrome number ';
}
}

echo Jutice_huiwen (' racecar ');

Test output:

The number of vowel letters is 10
The number of letters A is: 3
The number of letters E is: 0
The number of letter B is: 3
The number of Letter O is: 4
The number of letter U is: 0
Execution Time 0.042128086090088
Racecar is a palindrome number

Determines whether the input string is a palindrome number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.