PHP string end-to-end character case swaps, string case _ PHP Tutorial

Source: Internet
Author: User
The end character of the PHP string word is case-insensitive and the end character is case-insensitive. The end character of a PHP string is case-insensitive. The End character of the string must be case-insensitive. a string such as Ajourneyof, athousandmilesmustcantbeginwithasinglestep must be provided. The End character of a PHP string is case-insensitive.
Requirements

Returns A string such as "a journey of, a thousand 'Miles 'must can't \" begin \ "with A single step. ", which is changed to" a journeY oF, A thousanD 'mys' musT can't "begiN" witH A singlE steP through the PHP program."

Note:
1. if the last character of each word is in uppercase, it becomes in lowercase. if it is in lowercase, it becomes in uppercase.
2. you need to consider conversion in the form similar to can't.
3. punctuation marks (only consider, '".;) do not change.

Reference algorithm
 
Test
 " . $str1 . "
result:
" . convertLastChar($str1) . "

"; echo "source:
" . $str2 . "
result:
" . convertLastChar($str2) . "

"; echo "source:
" . $str3 . "
result:
" . convertLastChar($str3) . "

"; echo "source:
" . $str4 . "
result:
" . convertLastChar($str4) . "

"; echo "source:
" . $str5 . "
result:
" . convertLastChar($str5) . "

"; echo "source:
" . $str6 . "
result:
" . convertLastChar($str6) . "

";?>

Result:

source:A journey of, a thousand 'miles' must can't "begin" with a single step.result:a journeY oF, A thousanD 'mileS' musT can'T "begiN" witH A singlE steP.source:A journey of, a thousand 'miles' must can't "begin" with a single step. result:a journeY oF, A thousanD 'mileS' musT can'T "begiN" witH A singlE steP. source:A journey of, a thousand 'miles' must can't "begin" with a single step. a result:a journeY oF, A thousanD 'mileS' musT can'T "begiN" witH A singlE steP. A source:A journey of, a thousand 'miles' must can't "begin" with a single step. a Bresult:a journeY oF, A thousanD 'mileS' musT can'T "begiN" witH A singlE steP. A bsource:A journey of, a thousand 'miles' must can't "begin" with a single step. a b'result:a journeY oF, A thousanD 'mileS' musT can'T "begiN" witH A singlE steP. A B'source:A journey of, a thousand 'miles' must can't "begin" with a single step. a B"result:a journeY oF, A thousanD 'mileS' musT can'T "begiN" witH A singlE steP. A b"

We can see that it is as expected.

Question source

Http://blog.sijiaomao.com /? P = 98. if there is a change (with the added can't), according to the changed rule, the original answer is all wrong.

Token requires that A string such as a journey of, a thousand 'Miles 'must can't \ "begin \" with A single step .., through PH...

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.