How does php splice binary data into strings?

Source: Internet
Author: User
How does php splice binary data into strings? Binary php UTF-8 encoding

For example, the utf8 encoding of the character "you" is "E4BDA0 ".
There is an array $ arr
$arr = array(chr(228), chr(189), chr(160));

How can we splice it into one piece so that it can print the character "you "?
Help


Reply to discussion (solution)

$ Arr = array (chr (228), chr (189), chr (160); echo join ('', $ arr ); // You foreach ($ arr as $ v) echo $ v; for ($ I = 0; $ I
   
  

echo pack('H*', 'E4BDA0');echo hex2bin('E4BDA0');

$ Arr = array (chr (228), chr (189), chr (160); echo join ('', $ arr ); // You foreach ($ arr as $ v) echo $ v; for ($ I = 0; $ I
     
    

echo pack('H*', 'E4BDA0');echo hex2bin('E4BDA0');

Thank you ~ The following two are feasible ~
The strange thing is that I printed three characters in join yesterday ~ Today, join is available ~
I don't know how the join performance works ~

Join is faster than loop in the code.

Join is faster than loop in the code.
Before I improved a template engine, I sent two posts asking the regular expression to match tags ~ Unsuccessful
Helpless, I decided to write a syntax analyzer by myself ~ Unfortunately, PHP does not support high-performance items such as pointer and memory copy. I don't know how much performance will be lost when using this method ~

You cannot be afraid of it because you are "worried ".
Performance is compared. you have to do more.
Only comparisons can be used for identification!

Php is interpreted and executed, and each command takes a little time.
There are also many cycles, and the more time. Recursion is also a loop
Recognition Mode. string function loops are better than regular expressions.
You can use the iterator instead of loop by yourself.
......

You cannot be afraid of it because you are "worried ".
Performance is compared. you have to do more.
Only comparisons can be used for identification!

Php is interpreted and executed, and each command takes a little time.
There are also many cycles, and the more time. Recursion is also a loop
Recognition Mode. string function loops are better than regular expressions.
You can use the iterator instead of loop by yourself.
......
Thank you ~ Thank you very much ~

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.