Q:

How to set NULL in all keys of array which aren't defined? 

I have a PHP code like this:
$var = "
         <ul>
               <li class='".$this->data['active']['one']."'></li>
               <li class='".$this->data['active']['two']."'></li>
               <li class='".$this->data['active']['three']."'></li>
               <li class='".$this->data['active']['four']."'></li>
               <li class='".$this->data['active']['five']."'></li>
         </ul>
       ";

Always one key of this array data['active'] is defined.  I mean is sometimes only this is defined:

$this->data['active']['one'] 

And sometimes only this:

$this->data['active']['two']

And so on ..!  I want to say, I'm always faced with a lot of this kind of notice:

Notice: Undefined index: three in {path} on line {x}

Well, How can I set null to all other keys of that array?  I did that like this (but it doesn't work)
$this->data['active'][] = null;
$this->data['active']['one'] = 'classname'; // or ['two'] or ['three'] and so on

Again, just one of those array is fill (defined).  Ok well, is there any solution to I remove that Notice: ? 

A:

There are a few ways - perhaps something like this would simplify things:
Effectively you need to check that the key exists in the array before trying to use it in any way - the function ke is shorthand for key exists and uses the array_key_exists function to check that the specified key is available otherwise it returns a default empty string.  
<? php

    $active=$this->data['active'];

    function ke( $a, $k ){
        return array_key_exists( $k, $a ) ?  $a[ $k ] : '';  
    }

    $var = "
             <ul>
                   <li class='".ke( $active, 'one' )."'></li>
                   <li class='".ke( $active, 'two' )."'></li>
                   <li class='".ke( $active, 'three' )."'></li>
                   <li class='".ke( $active, 'four' )."'></li>
                   <li class='".ke( $active, 'five' )."'></li>
             </ul>
           ";
? >

