Index and Array problem
| From: | Louie Miranda | Date: | Fri, 26 Jan 2007 02:27:05 +0000 |
| Subject: | Index and Array problem | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26419@lists.php.net to get a copy of this message | ||
Is it possible to manipulate the index of an array?
my code..
initialize the arrays..
$secondary = array();
$secondary[1] = array(); $secondary[2] = array(); $secondary[3] = array();query the database $fedex =& $db->query('SELECT * from scalc_zone_fedex order by country'); //
has id and country fields
while ($row_fedex = $fedex->fetchRow(MDB2_FETCHMODE_ASSOC)) {
//echo $row['country'] . "\n";
//$secondary[1] = $row['country'];
array_push($secondary[1], $row_fedex['country']);
}
print $secondary array
print_r($secondary)
result of the array
was thinking is get the field id $row_fedex['id'] and display the result of the id as the index. But, i am quite lost already. How can i do that? I've tried editing this one.. array_push($secondary[1], $row_fedex['country']);[1] => Array ( [0] => Afghanistan [1] => Albania [2] => American Samoa [3] => Andorra [4] => Angola [5] => Anguilla[6] => Antigua [7] => Argentina [8] => Armenia [9] => Aruba [10] => Australia [11] => Austria [12] => Azerbaijan[13] => Bahamas [14] => Bahrain [15] => Bangladesh [16] => Barbados [17] => Belarus [18] => Belgium [19] => Belize[20] => Benin)Now, the problem i got is. The index should not start from 0 to 20. What i
into array_push($secondary[1].$row_fedex['id'], $row_fedex['country']);But its all wrong.. PHP Fatal error: Only variables can be passed by reference Please help! -- Louie Miranda ( lmiranda@gmail.com) http://www.axishift.com //JSM-W