Re: help with arrays

From: Date: Tue, 23 Sep 2003 21:06:27 +0000
Subject: Re: help with arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-163637@lists.php.net to get a copy of this message
Of course, you could do it in a much more cryptic way... just for fun. :-) INPUT: <?php $a = array( '0' => 'j',
            'fname' => 'j',
            '1' => 'j',
            'lname' => 'j',
            '2' => 'jj',
            'state' => '',
            '3' => 'j@domain.com',
            'email' => 'j@domain.com',
            '4' => '0',
            'newsletter' => '0',
                );
array_walk($a, create_function('&$v', '$v = ($v=="")?"&nbsp;":$v;')); print_r($a); ?> OUTPUT: petej@computer$ php -f test.php Array (
    [0] => j
    [fname] => j
    [1] => j
    [lname] => j
    [2] => jj
    [state] => &nbsp;
    [3] => j@domain.com
    [email] => j@domain.com
    [4] => 0
    [newsletter] => 0
) Chris W. Parker wrote:
Hey people. I've got an array like this:
    [0] => Array
        (
            [0] => j
            [fname] => j
            [1] => j
            [lname] => j
            [2] => jj
            [state] => jj
            [3] => j@domain.com
            [email] => j@domain.com
            [4] => 0
            [newsletter] => 0
        )
Some cells might be empty so i want to replace every empty cell with "&nbsp;". I can easily do this with just the numerical index but I can't figure out how to do the textual indices also. Someone have a clue? Thanks, Chris.


« previous php.general (#163637) next »