Q:

How do i remove multiple array elements in PHP?

I have an array 
$rules = array(
    'name' => array(
        'isRequired' => array(
            'message' => 'Name Required'
         ),
        'isBetween' => array(
              'value' => array(5,15),
              'message' => 'Between 5 to 15 characters'
        ),
        'isAlphaLower' => array(
            'message' => 'Should be Alpha lower'
        ),
        'isLength' => array(
            'value' => 20,
            'message' => 'Length should be 20 chracters'
        )
    ),
    'email' => array(
        'isEmail' => array(
            'message' => 'Email should be valid'
        ),
        'isRequired' => array(
            'message' => 'Email Required'
        ),
    ),
    'pPhone' => array(
        'isNumber' => array(
            'message' => 'Only Numbers'
        )
    )
);

I need to remove all array element with key name message. how do i do that?
thank you.. 

A:

Nested foreach, by reference.

foreach( $rules as $field => &$fieldrules ) {
    foreach( $fieldrules as $rulename => &$rulesettings ) {
        unset( $rulesettings['message'] );
    }
}

