PHP gevorderde |
|
Beste,
Ik heb een meer dimensionale array en bij sommige keys wil ik een array toevoegen.
ik heb dit:
<?php
[5]=>
array(12) {
["id"]=>
string(2) "10"
["parent_id"]=>
string(1) "5"
["art_id"]=>
string(2) "14"
["artoptions_id"]=>
string(1) "0"
["title"]=>
string(0) ""
["quantity"]=>
string(0) ""
["price"]=>
string(0) ""
["language"]=>
string(0) ""
["active"]=>
string(4) "true"
["isagroup"]=>
string(4) "true"
["created"]=>
string(10) "0000-00-00"
["deleted"]=>
string(5) "false"
}
[6]=>
array(12) {
["id"]=>
string(2) "11"
["parent_id"]=>
string(1) "5"
["art_id"]=>
string(2) "13"
["artoptions_id"]=>
string(1) "0"
["title"]=>
string(0) ""
["quantity"]=>
string(0) ""
["price"]=>
string(0) ""
["language"]=>
string(0) ""
["active"]=>
string(4) "true"
["isagroup"]=>
string(4) "true"
["created"]=>
string(10) "0000-00-00"
["deleted"]=>
string(5) "false"
}
}
?>
<?php [5]=> ["id"]=> string(2) "10" ["parent_id"]=> string(1) "5" ["art_id"]=> string(2) "14" ["artoptions_id"]=> string(1) "0" ["title"]=> string(0) "" ["quantity"]=> string(0) "" ["price"]=> string(0) "" ["language"]=> string(0) "" ["active"]=> string(4) "true" ["isagroup"]=> string(4) "true" ["created"]=> string(10) "0000-00-00" ["deleted"]=> string(5) "false" } [6]=> ["id"]=> string(2) "11" ["parent_id"]=> string(1) "5" ["art_id"]=> string(2) "13" ["artoptions_id"]=> string(1) "0" ["title"]=> string(0) "" ["quantity"]=> string(0) "" ["price"]=> string(0) "" ["language"]=> string(0) "" ["active"]=> string(4) "true" ["isagroup"]=> string(4) "true" ["created"]=> string(10) "0000-00-00" ["deleted"]=> string(5) "false" } } ?>
nu wil ik aan key 6 dit toevoegen:
<?php
array(4) {
[0]=>
array(4) {
["id"]=>
string(1) "4"
["art_id"]=>
string(2) "12"
["option"]=>
string(13) "toegift_title"
["value"]=>
string(22) "Hxxxx"
}
[1]=>
array(4) {
["id"]=>
string(1) "5"
["art_id"]=>
string(2) "12"
["option"]=>
string(11) "toegift_img"
["value"]=>
string(34) "Hxx.jpg"
}
[2]=>
array(4) {
["id"]=>
string(1) "6"
["art_id"]=>
string(2) "12"
["option"]=>
string(12) "toegift_size"
["value"]=>
string(23) "Acryl op doek, 24x30 cm"
}
[3]=>
array(4) {
["id"]=>
string(1) "7"
["art_id"]=>
string(2) "12"
["option"]=>
string(12) "xxx"
["value"]=>
string(111) "xxx"
}
?>
<?php [0]=> ["id"]=> string(1) "4" ["art_id"]=> string(2) "12" ["option"]=> string(13) "toegift_title" ["value"]=> string(22) "Hxxxx" } [1]=> ["id"]=> string(1) "5" ["art_id"]=> string(2) "12" ["option"]=> string(11) "toegift_img" ["value"]=> string(34) "Hxx.jpg" } [2]=> ["id"]=> string(1) "6" ["art_id"]=> string(2) "12" ["option"]=> string(12) "toegift_size" ["value"]=> string(23) "Acryl op doek, 24x30 cm" } [3]=> ["id"]=> string(1) "7" ["art_id"]=> string(2) "12" ["option"]=> string(12) "xxx" ["value"]=> string(111) "xxx" } ?>
ik heb de volgende code:
<?php
function getOrders()
{
$sQuery = "SELECT
*
FROM
sale
";
/* JOIN
art
ON
sale.art_id = art.id*/
$rs = $this->conn->Execute($sQuery);
$aReturn = array();
while(!$rs->EOF)
{
if ($rs->fields['artoptions_id'] != 0)
{
//var_dump($rs->fields); exit;
$aReturn[] = $rs->fields;
$index = sizeof($aReturn) - 1;
echo $sQuery = "SELECT
*
FROM
artoptions
WHERE
art_id = '".intval($rs->fields['art_id'])."'
AND
artoptions.option like 'toegift%'
";
/* JOIN
art
ON
sale.art_id = art.id*/
$rs = $this->conn->Execute($sQuery);
$aOptions = array();
while(!$rs->EOF)
{
$aOptions[] = $rs->fields;
$rs->MoveNext();
}
$aReturn[$index] = $rs->fields;
$aReturn[$index] = $aOptions;
}
else{
$aReturn[] = $rs->fields;
}
$rs->MoveNext();
}
var_dump($aReturn); exit;
return $rs;
}
?>
<?php function getOrders() { $sQuery = "SELECT * FROM sale "; /* JOIN art ON sale.art_id = art.id*/ $rs = $this->conn->Execute($sQuery); while(!$rs->EOF) { if ($rs->fields['artoptions_id'] != 0) { //var_dump($rs->fields); exit; $aReturn[] = $rs->fields; $index = sizeof($aReturn) - 1; * FROM artoptions WHERE art_id = '".intval($rs->fields['art_id'])."' AND artoptions.option like 'toegift%' "; /* JOIN art ON sale.art_id = art.id*/ $rs = $this->conn->Execute($sQuery); while(!$rs->EOF) { $aOptions[] = $rs->fields; $rs->MoveNext(); } $aReturn[$index] = $rs->fields; $aReturn[$index] = $aOptions; } else{ $aReturn[] = $rs->fields; } $rs->MoveNext(); } return $rs; } ?>
in regel 44 / 45 gaat iets niet goed...
weet iemand een oplossing??
|