Function parameter: true? How to solve this problem-php Tutorial

Source: Internet
Author: User
Function parameter: true? This post was last edited by u012362664 from 2013-10-0920: 35: 48 & lt ;? & Nbsp; $ x1array (1 & gt; 111,2 & gt; 12,3 & gt; 3333); & nbsp; & nbsp; $ y1 function parameter: true?

This post was last edited by u012362664 at 20:35:48, January 9 ,.



$x1=array(1=>111,2=>12,3=>3333);
$y1=in_array(12,$x1,true);
echo $y1;
echo "\r\n";

$x2=array(1=>111,2=>12,3=>3333);
$y2=in_array('12',$x2,true);
echo $y2;
echo "\r\n";

$x3=array(1=>111,2=>12,3=>3333);
$y3=in_array("12",$x3,true);
echo $y3;
echo "\r\n";

?>


Program output:
1
0
0


Problem:
1. the above program is compiled without syntax errors.
The in_array () function contains 1st parameters, all of which are int integers.

The in_array () function has 3rd parameters: true. what is the role?

Why, 1st arrays, return result: 1, find.
Returns 0 for every 2 or 3 arrays. cannot be found?


Share To: 111,2 => 3333 => );????? $ Y1 = in_array (12, $ x1, true );????? Echo? $ Y1 ;???... 'Data-pics = ''>


------ Solution --------------------
The landlord, 12 is a number, '12' and "12" are strings, so the type is different

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.