-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Description
Description
The following code:
$array1=['289','290','297'];
$array2=['289','290','297'];
$num=0;
while ($num<count($array1))
{
echo print_r($array1,true);
echo '<br>';
echo print_r($array2,true);
$t=$array1[$num];
echo '<br>';
echo $t;
echo '<br>';
if (array_search($t,$array2,TRUE))
{
echo 'This matched: '.$array1[$num];
}
echo '<br>';
$num++;
}
Resulted in this output:
Array ( [0] => 289 [1] => 290 [2] => 297 )
Array ( [0] => 289 [1] => 290 [2] => 297 )
289
Array ( [0] => 289 [1] => 290 [2] => 297 )
Array ( [0] => 289 [1] => 290 [2] => 297 )
290
IThis matched: 290
Array ( [0] => 289 [1] => 290 [2] => 297 )
Array ( [0] => 289 [1] => 290 [2] => 297 )
297
This matched: 297
But I expected this output instead:
Array ( [0] => 289 [1] => 290 [2] => 297 )
Array ( [0] => 289 [1] => 290 [2] => 297 )
289
This matched: 289
Array ( [0] => 289 [1] => 290 [2] => 297 )
Array ( [0] => 289 [1] => 290 [2] => 297 )
290
IThis matched: 290
Array ( [0] => 289 [1] => 290 [2] => 297 )
Array ( [0] => 289 [1] => 290 [2] => 297 )
297
This matched: 297
PHP Version
PHP 8.1.2
Operating System
Windows 10- 10.0.19044 N/A Build 19044