|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-04-09 16:18 UTC] spawnm at spawnm dot pl
Description:
------------
PHP Version: 5.4.6-1ubuntu1.2
$arr = array ( 'error' => true );
echo in_array('lol', $arr)? 1: 0;//1
$arr = array ( 'error' => 'true' );
echo in_array('lol', $arr)? 1: 0;//0
Test script:
---------------
$arr = array ( 'error' => true );
echo in_array('lol', $arr)? 1: 0;//1
$arr = array ( 'error' => 'true' );
echo in_array('lol', $arr)? 1: 0;//0
Expected result:
----------------
$arr = array ( 'error' => true );
echo in_array('lol', $arr)? 1: 0;//1
$arr = array ( 'error' => 'true' );
echo in_array('lol', $arr)? 1: 0;//0
Actual result:
--------------
$arr = array ( 'error' => true );
echo in_array('lol', $arr)? 1: 0;//1
$arr = array ( 'error' => 'true' );
echo in_array('lol', $arr)? 1: 0;//0
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 02:00:01 2025 UTC |
By default in_array uses == comparison (and true == 'lol'). If you want to use strict === comparison pass "true" as an additional parameter: in_array('lol', $arr, true);