You guys, read strings through php.-php Tutorial

Source: Internet
Author: User
Ladies and gentlemen, read strings via php for help $ str =" Thank you!
Bi Dandan
Ma Chaoli
Li Xin
Li Ping ";
When such a string is processed using php, a new array (name, count value) is obtained );
For example, generate $ ars = array ('0' => 'Xie shares', '0' => 'bidandan ', '0' => 'ma Chaoli ', '0' => 'Li Xin', '1' => 'Li ping ');

Thank you for your help.


Reply to discussion (solution)

$ Str ="
 
  
Thank you!
 
 
  
Bi Dandan
 
 
  
Ma Chaoli
 
 
  
Li Xin
 
 
  
Li Ping
 "; Preg_match_all ("/
 
  
(.*?) <\/V: note>/", $ str, $ matches); $ newArr = array_combine ($ matches [2], $ matches [1]); var_dump ($ newArr);?>
 

The php array does not have the same key value. Therefore, only names can be used as key values to ensure uniqueness.

It is impossible to generate the type you want. The same key cannot exist at the same time. The latter will overwrite the former.

Only array ('0' => 'Xie qing', '1' => 'bidand', '2' => 'ma Chaoli ', '3' => 'Li Xin', '4' => 'Li ping'); similar to this.

Your count cannot be a key.

$ Str ="
 
  
Thank you!
 
 
  
Bi Dandan
 
 
  
Ma Chaoli
 
 
  
Li Xin
 
 
  
Li Ping
 "; Preg_match_all ("/
 
  
(.*?) <\/V: note>/", $ str, $ matches); $ newArr = array_combine ($ matches [2], $ matches [1]); var_dump ($ newArr);?>
 

The php array cannot have the same key value. Therefore, only the name can be used as the key value to ensure that the unique result contains a string array (5 ){
["Thank you"] =>
String (1) "0"
["Bi Dan"] =>
String (1) "0"
["Ma Chaoli"] =>
String (1) "0"
["Li Xin"] =>
String (1) "0"
["Li Ping"] =>
String (1) "1"
}
Can this string be removed?

It is impossible to generate the type you want. The same key cannot exist at the same time. The latter will overwrite the former.

Only array ('0' => 'Xie qing', '1' => 'bidand', '2' => 'ma Chaoli ', '3' => 'Li Xin', '4' => 'Li ping'); similar to this.

Your count cannot be used as the key. I only need to be able to sort by the value in the count header.


There is no string where the string is output elsewhere.


There is no string. the string is output elsewhere. thank you for your score.

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.