mein Array bestehtextrahieren Wert für relativen Schlüssel von Array
Das FORM-Ergebnis zieht in $ _POST Array dieses Typs.
Position [0] => Array, zeigt mir die genaue Tasten - [0] => Array (1,4,5) -
Hallo! mein Array Extrakt nach Form ist:
Array
(
[chk] => Array
(
[0] => 1
[1] => 4
[2] => 5
)
[ID] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
[firstAttr] => Array
(
[0] => Sun
[1] => Love
[2] => Fruit
[3] => Dog
[4] => Sky
)
[secondAttr] => Array
(
[0] => Big
[1] => intense
[2] => Delicious
[3] => Black
[4] => Blue
)
[otherAttr] => Array
(
[0] => White
[1] => Red
[2] => Orange
[3] => Old
[4] => Nice
)
)
mein Ergebnis Anforderung Gruppe [CHK].
Ich muss nur die Werte herausnehmen, die zur [chk] Gruppe gehören.
Beispiel:
[chk] => Array
(
[0] => 1
[1] => 4
[2] => 5
)
ID [0] => 1, firstAttr [0] => Sun, secondAttr [0] => Big, otherAttr [0] => White
ID [3] => 4, firstAttr [3] => Dog, secondAttr [3] => Black,otherAttr [3] => Old
ID [4] => 5, firstAttr [4] => Sky, secondAttr [4] => Blue, otherAttr [4] => Nice
Ergebnis-Array.
I aus extrahiert [input type = "checkbox" name = "chk []"] die Werte 1,4,5
jetzt habe ich die Werte extrahieren, indem Sie auf diese Tasten verweisen:
im Beispiel sind das: [chk] => Array (1,4,5). Versuchen
RESULT [chk] group:
1 = Sun, Big, White
4 = Dog, Black, Old
5 = Sky, Blue, Nice
$selectAll = $_POST;
$chk = $_POST['chk'];
$chkcount = count($chk);
$result = array();
foreach ($chk as $index) {
$result[$index]['ID'] = $selectAll['ID'][$index-1];
$result[$index]['firstAttr'] = $selectAll['firstAttr'][$index-1];
$result[$index]['secondAttr'] = $selectAll['secondAttr'][$index-1];
$result[$index]['otherAttr'] = $selectAll['otherAttr'][$index-1];
}
print_r($result);
$ chk = $ _POST [0] [ 'chk']; versuchen Sie diese – Sona
was erwartetes Ergebnis ist. Stellen Sie das klar fest –