Php string to array

Source: Internet
Author: User
Tags eval explode php code

 
$ Str = "corn, broccoli, zucchini ";
$ Ar = explode (",", $ text );
Print_r ($ ar );
/*
Definition and usage
The explode () function separates strings into arrays.
 
Syntax
Explode (separator, string, limit) parameter description
Separator is required. Specifies where to split the string.
String is required. The string to be split.
Limit is optional. Specifies the maximum number of returned array elements.
*/
 
$ Biuuu = 'www .111cn.net ';
Print_r (str_split ($ biuuu ))
/*
Definition and usage
The str_split () function separates strings into arrays.
 
Syntax
Str_split (string, length) parameter description
String is required. Specifies the string to be split.
Length is optional. Specifies the length of each array element. The default value is 1.
*/
 
//
$ Str = "$ str = $ str ;";
Eval ($ str );
 
$ String = 'cup ';
$ Name = 'coffee ';
$ Str = '$ name is included in $ string. <br> ';
Echo $ str;
Eval ("$ str =" $ str ";");
Echo $ str;

// The eval () function returns the string corresponding to the php code.
 
 
$ Str = "1: 0: 1: 0: 1 ";
$ Arraylist = split (":", $ str); // store an array
 
For ($ I = 0; $ I <count ($ arraylist); $ I ++) // output all of them
 {
Echo $ arraylist [$ I]. "";
 }

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.