Ich habe die Variable $request
. Wenn ich vardump($request)
tun, bekomme ich die Ausgabe von:Ausgabe des Arrays immer gleich 'i'
array(7) {
["controller"]=> string(5) "index"
["action"]=> string(5)"index"
["module"]=> string(7) "default"
[2]=> array(8) {
["g_goal_list_id"]=> string(3) "127"
["textgoal"]=> string(9) "eats food"
["task_0"]=> string(1) "0"
["value_0"]=> string(5) "pukes"
["task_1"]=> string(1) "0"
["value_1"]=> string(0) ""
["task_2"]=> string(1) "0"
["value_2"]=> string(0) ""
}
[3]=> array(10) {
["g_goal_list_id"]=> string(3) "128"
["textgoal"]=> string(9) "goes home"
["task_0"]=> string(1) "0"
["value_0"]=> string(20) "but never comes back"
["task_1"]=> string(1) "0"
["value_1"]=> string(14) "stays home now"
["task_2"]=> string(1) "0"
["value_2"]=> string(0) ""
["task_3"]=> string(1) "0"
["value_3"]=> string(0) ""
}
["submit"]=> string(4) "Save"
["task"]=> string(1) "5"
}
, die alle korrekt ist. Aber ich versuche, eine foreach statment zu verwenden, um Werte aus dem $request
Array zu greifen und sie in eine data
gestellt habe, und dann, dass db zum mysql einreichen ...
foreach($request as $currentrow){
//skips row if the field is empty
if(strlen($currentrow['value']) < 1)//need to make sure I've defined $currentrow['value']
continue;//skips row with empty field
//I only need to grab the value/list_id/account_id from the form
$data = array('value' => $currentrow['value'],
'g_goal_list_id' => $currentrow['g_goal_list_id'],
'account_id' => g_getAccountId(),
);
var_dump($data);
Allerdings, wenn ich meine var_dump($data);
Ausgabe sieht wie folgt aus:
array(3) { ["value"]=> string(1) "i" ["g_goal_list_id"]=> string(1) "i" ["account_id"]=> string(1) "1" }
array(3) { ["value"]=> string(1) "S" ["g_goal_list_id"]=> string(1) "S" ["account_id"]=> string(1) "1" }
array(3) { ["value"]=> string(1) "5" ["g_goal_list_id"]=> string(1) "5" ["account_id"]=> string(1) "1" }
das einzige, was in diesem var_dump($data)
richtig ist, ist die ["account_id"]
ich denke, dass meine Schleife falsch ist, und ich bin ziemlich schlecht mit Schleifen. Sooooo ja, hoffentlich habe ich genügend Informationen aufgenommen. Vielen Dank.
ändern Können Sie bearbeiten Ihre Frage die Ausgabe von 'Echo liefern '
';' statt 'var_dump ($ _ REQUEST);' bitte? Es wird Ihre Arrays viel besser lesbar machen und Ihnen helfen, ihre Hierarchien aufzuzeigen. Machen Sie das gleiche mit '$ data', bitte. Vielen Dank. – MonkeyZeus$ data = array ('wert' => $ currentrow ['werte'], // sollte das nicht sein $ currentrow ['wert'] ??? –
Ich konnte die Ausgabe der Daten nicht bearbeiten : 'echo '
';' –