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