Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this array and would like to get the values and keysin a flat array please help,
Array ( [0] => Array ( [DT] => 4 [NO_Calls] => 300 [Agents] => 8001 ) [1] => Array ( [DT] => 4 [NO_Calls] => 6000 [Agents] => 8002 ) )

this is the code for mysql

PHP
public function selectJ($query) {
    $rows = array();
            $result = $this -> db_query($query);

            if($result === false) {
                    return false;
            }

            while ($row = mysqli_fetch_assoc( $result)) {
                    $rows[] = $row;
            }
        return $rows;
        }





i would like it to be something like this

Array ( [DT] => 4 [NO_Calls] => 300 [Agents] => 8001 [DT] => 4 [NO_Calls] => 6000 [Agents] => 8002 )
Posted

1 solution

You can't. The outcome you want is an associate array with key-value pairs but associate array cannot have duplicate keys, i.e. [DT], [NO CALL], etc.
http://www.w3schools.com/php/php_arrays.asp[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900