Page 1 of 1

array question

Posted: Tue Jun 14, 2005 5:27 am
by shiznatix
i have a array that looks kinda like this

Code: Select all

[0] => 'cool things here',
[base_skills] => ''
but when i do

Code: Select all

if (isset($array['base_skills']))
{
    echo 'cool it worked';
}
it dosn't work but i need it to work so if you could help me make it work that would be terrific

Posted: Tue Jun 14, 2005 6:18 am
by JayBird
works for me

Code: Select all

$array = array(0 => 'cool things here', 'base_skills' => '');

if (isset($array['base_skills'])){
	echo 'cool it worked';
}

Posted: Tue Jun 14, 2005 6:29 am
by shiznatix
exactly what i am seeing


print_r($qf_map) outputs this ->

Code: Select all

Array
(
    ї1] =>  
                LEFT JOIN
                    mdl_cv_personal_info AS person
                ON
                    person.fk_user_id = base.user_id 
                   
    їbase_skills] => 
)

Code: Select all

if ($qf_map['base_skills'])
{
    echo 'worked for me!';
}
//this does not work ^

//this DOES work
if ($qf_map['base_skills'] == '')
{
    echo 'worked for me right here!';
}
but it is definatly not working, why?

Posted: Tue Jun 14, 2005 6:41 am
by timvw
If $ar['foo'] equals to "", it will evaluate as FALSE. (As explained in http://www.php.net/manual/en/language.c ... uctures.if and http://www.php.net/manual/en/language.t ... an.casting)

Interesting functions: empty, isset, array_key_exists.