PHP Chinese string Inversion instance code

Source: Internet
Author: User
Tags array to string

PHP Chinese string Inversion instance code
The PHP string inversion function, String Strrev (String $str), has only one parameter, which is the string to invert. Instance Program:
Echostrrev ("Hello world!"); Outputs "!dlrowolleh" UTF8 Chinese string Inversion instance code:
function Strrev_utf8 ($STR) {return join ("", Array_reverse (Preg_split ("//u", $str)));}
Print (Strrev_utf8 ("Hello, PHP Code Bar"));//output: Bar code generation PHP, good you
PHP array to string –join method php Array to string method Many, the most primitive idea is to use a for loop, to iterate through the string in the array. In this article we use the Join method.
The Join method has two parameters, the first parameter specifies the contents of the connection string, and the second parameter is the array instance code: $array = Array (' LastName ', ' email ', ' phone '); $comma _separated = Join (",", $array);
echo $comma _separated; Lastname,email,phone the case of multidimensional arrays:
Functionjoinr ($join, $value, $lvl =0)

PHP Chinese string Inversion instance code

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.