Implode a multidimensional array

Discussion in 'PHP' started by makamo66, Oct 1, 2013.

  1. #1
    I have an array from a database select query that looks like this;

    Array ( [0] => Array ( [0] => Array ( [users] => Array (
     
    makamo66, Oct 1, 2013 IP
  2. makamo66

    makamo66 Active Member

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    The answer from a different forum is
    <?php
        $all = array(
            array(
                array('users' => array('email' => 'makamo66@hotmail.com')),
                array('users' => array('email' => 'makamo77@hotmail.com'))
                )
            );
        $cleanarray = array();
        foreach ($all[0] as $key => $value) {
            array_push($cleanarray, $value['users']['email']);
        }
        $comma_separated = implode(",", $cleanarray);
        echo $comma_separated;
    ?>
    Code (markup):
     
    makamo66, Oct 1, 2013 IP