[New person] ask all PHPER to run the code in the workshop and then talk about your feelings! & Nbsp; $ arrarray (aaa & gt; 123234.232342, dfwee & gt; asdfas2131-safa, drged & gt; 1234, kjyr & gt; 1, bnt & gt; true); & nbsp; & nbsp; & nbsp [new person] ask all phers to run the following code in the samples and talk about their feelings!
$arr=array('aaa'=>"123234.232342",'dfwee'=>"asdfas/2131-safa",'drged'=>1234,'kjyr'=>1,'bnt'=>true);
foreach($arr as $key=>$val){
echo "{$val}==1234 resault is:".($val==1234)." || {$val}===1234 resault is:".($val===1234)."
";
}
Share: More
------ Solution --------------------
I think you're confused about this.
'Bnt '=> true
1 == 1234 resault is: 1
------ Solution --------------------
1 === 1234 resault is:
Only true is displayed as 1.
True = 1234 resault is: 1
------ Solution --------------------
True === 1234 resault is:
Is it clear?
1234 is a non-null value. it is logical (true), so is: 1
True = 1234 at the same time, check whether the data types are consistent. Obviously, a logical type and a numeric type are inconsistent, so it is:
During output, true is printed as 1 and false is printed as null.
------ Solution --------------------
Because php is weak, and the weak type is closer to the natural language
What's more, you need to convert the data type from the source. don't you bother?
------ Solution --------------------
Is there any array_search in your code? why is it so miserable?
------ Solution --------------------
It is strange that most of the array data comes from databases or files. Naturally, each element has the same data type.
No need to judge the type?