I'm using : PHP 8.0.9 (cli) (built: Jul 29 2021 14:12:19) and LARAVEL 8.
I don't know for some reason after pushing element to $s
, the $s
(outside loop) wont update it's value to ["...",".","ok"]
. I'm using Illuminate\Support\Arr::exists()
to check if the value already added to $s
. I keep getting ["...",".","ok","ok","ok"]
. What i want is ["...",".","ok"]
. Is anyone know what im doing is wrong?
Thanks.
public function showImportForm(){ // ignore this
if ($_SESSION['current'] == session_id()) { // ignore this
$s = array("...", ".");
for ($i=1; $i<=3; $i++){
if(!Arr::exists($s, "ok")){
$s[] = "ok";
}else{
print("skip");
}
}
return $s;
//return view('database.import');
}
}
`
Just have a look at the definition of Arr::exists
:
Determine if the given key exists in the provided array.
That method does not check whether the value is already present in the array. Use in_array
instead