CI irrelevant, but help please

Hi, this is CI irrelevant, but i need ur help.

Im checking if $value exists in $Temp arary or not. The code as following:

$value = '123';    
        $Temp = array();
        if (!$Temp =[$value]) {
            $Temp =[$value] = '1';
        } else {
            echo $value.'exist in array';    

It generate me the following error :

Severity: Notice
Message: Undefined index: 123

Any idea ?

that's some weird code Smile
If you just created the array nothing is in it so you don't need to check if the $value exists.
I'm not sure if you want to check if the value is present in the array as a key or as a value.
If you want to check if the key exists
If you want to check if the value exists (in a one dimensional array)

why don´t you use the native php functions for this??
in_array() - value exists

gunters solution for searching the value is better (less functions) and for the key you could use

cheers guys ...
got it solved ...
million thanks

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.