Last active
August 29, 2015 14:20
-
-
Save jbdelhommeau/e4abb53ce78ca0c4467e to your computer and use it in GitHub Desktop.
Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function getFieldDataValue(NoticeDataLang $fieldData) | |
{ | |
if ($fieldData->getField()->getType() !== Field::TYPE_SET) { | |
return [$fieldData->getField()->__toForm() => $fieldData->getValue(false)]; | |
} | |
if ($fieldData->getChildren()) { | |
$childData = []; | |
foreach ($fieldData->getChildren()->toArray() as $child) { | |
array_push($childData, [$child->getPart() => $this->getFieldDataValue($child)]); | |
} | |
return $childData; | |
} | |
return []; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function getFieldDataValue(NoticeDataLang $fieldData) | |
{ | |
if ($fieldData->getField()->getType() !== Field::TYPE_SET) { | |
return [$fieldData->getField()->__toForm() => $fieldData->getValue(false)]; | |
} | |
if ($fieldData->getChildren()) { | |
$childData = []; | |
foreach ($fieldData->getChildren()->toArray() as $child) { | |
if (isset($childData[$child->getPart()])) { | |
$childData[$child->getPart()] = array_merge( | |
$childData[$child->getPart()], | |
$this->getFieldDataValue($child) | |
); | |
} else { | |
$childData[$child->getPart()] = $this->getFieldDataValue($child); | |
} | |
} | |
return $childData; | |
} | |
return []; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$iterate_1 = array(1 => array('key11' => 'value11')); | |
$iterate_2 = array(1 => array('key12' => 'value12')); | |
$iterate_3 = array(2 => array('key21' => 'value21')); | |
$iterate_4 = array(2 => array('key22' => 'value22')); | |
J'ai ses valeurs à chaque tour de boucle et je dois la "fusionner" à chaque élément précédent. | |
Le résultat doit-être: | |
$result = array( | |
1 => array( | |
'key11' => 'value11', | |
'key12' => 'value12', | |
), | |
2 => array( | |
'key21' => 'value21', | |
'key22' => 'value22', | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment