Explode in php to check whether a character exists

Source: Internet
Author: User
Tags explode php tutorial

In the php Tutorial, use explode to check whether a character exists.

Explode (string separator, string [, int limit])
Separator is a null string (""), and explode () returns FALSE. If the value of separator cannot be found in string, explode () returns an array containing a single string element.
 
*/
// Explode instance 1
$ Explode = "aaa, bbb, ccc, ddd, explode, jjjj ";
$ Array = explode (',', $ explode );
Print_r ($ array );
/*
Result:
Array
(
[0] => aaa
[1] => bbb
[2] => ccc
[3] => ddd
[4] => explode
[5] => JJJJJ
)
*/
// We can use the explode and end functions when processing the date or getting the file extension. The following shows the example.
$ File = "www.111cn.net.gif ";
 
$ ExtArray = explode ('.', $ file );
$ Ext = end ($ extArray );
Echo $ ext;
 
/*
Output value: .gif

Use explode to find whether a character exists

<? Php
If ($ _ MODULE [tg1_tjly]) {
$ Tg1_tjly = explode ("|", $ _ MODULE [tg1_tjly]);
If (count ($ tg1_tjly)> 1) {// here, when the statistical array is greater than 1, it indicates that it contains one or more interval symbols "| ".
$ Tg1_tjly_tit = $ tg1_tjly [0];
$ Tg1_tjly_con = $ tg1_tjly [1];
} Else {
$ Tg1_tjly_tit = 'reason for recommendation ';
$ Tg1_tjly_con =$ _ MODULE [tg1_tjly];
   }
} Else {
$ Tg1_tjly_tit = 'Enter the Recommendation reason title ';
$ Tg1_tjly_con = 'Enter the content of the Recommendation reason. ';
  } 
?>

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

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.