General Community > Scripting Help
PHP array question
(1/1)
CapadY:
I'm using the next code and get an error message about an unallowed double arrow:
--- Code: --- $settings_array = array();
While ($row = mysql_fetch_array($settings_result)) {
$settings_array[] = ($row['label'] => $row['inhoud']);
}
--- End code ---
Somebody who can tell me how to get an key with value in this array ?
CapadY:
oke, solved with:
--- Code: --- $settings_array[] = ($row['label'].'=>'.$row['inhoud']);
--- End code ---
Arantor:
Um, surely you want:
--- Quote --- $settings_array = array();
while ($row = mysql_fetch_assoc($settings_result)) {
$settings_array[$row['label']] = $row['inhoud'];
}
--- End quote ---
MrPhil:
You are trying to put some value in a new element for $settings_array? How does this new element's value relate to (formed from) $row['label'] and $row['inhoud']? Are you intending to just create the "next" numbered element, or is this an associative array where you want to "name" the row?
Navigation
[0] Message Index
Go to full version