En fait le topo :
#SET{trier,#ARRAY{}}
<BOUCLE_articles(ARTICLES){id_rubrique IN 6}>
[(#SET{trier,[(#GET{trier}|push{
[(#ARRAY{
objet,« article »,
date,#DATE,
photo,#LOGO_ARTICLE,
titre2,#TITRE
})]})]})]
</BOUCLE_articles>
#SET{tab,#ARRAY{}}
<BOUCLE_tab0(DATA){source json, doc} >
[(#SET{fb,[(#GET{fb}|push{[(#ARRAY{
id,#VALEUR{id},
image,#VALEUR{picture}
})]})]})]
</BOUCLE_tab0>
< BOUCLE_tab1(DATA){source json,doc} >
[(#SET{fb,[(#GET{fb}|push{ [(#ARRAY{
id,#VALEUR{id},
url,#VALEUR{link}
})]})]})]
</BOUCLE_tab1>
<BOUCLE_tab2(DATA){source json,doc} >
[(#SET{fb,[(#GET{fb}|push{ [(#ARRAY{
id,#VALEUR{id},
ladate,#VALEUR{created_time},
txt,#VALEUR{message}
})]})]})]
</BOUCLE_tab2>
Pour chaque boucle tabx il y a un id commun, le tout est de regrouper l’ensemble tab par rapport à cet id et de l’intégrer au tableau trier.
Le 4 avr. 2017 à 15:10, nicod_ <nicolas.dorigny@gmail.com> a écrit :
Le 04/04/2017 à 14:21, Laetitia Boiron a écrit :
Bonjour,
je cherche à fusionner des tableaux ayant le même id mais des clés/valeurs différentes. Le tableau est le même SET{tableau,#ARRAY}. Comment faire ? Sachant que cette fusion doit rejoindre un autre tableau #ARRAY aux contenus hétérogènes.
Je ne comprends pas bien « des tableaux ayant le même id », mais fusionner deux tableaux se fait avec array_merge en PHP, qu’on peut utilise comme filtre.
Par exemple :
#SET{tab1,#ARRAY{…}}
#SET{tab2,#ARRAY{…}}
#SET{fusion, #GET{tab1}|array_merge{#GET{tab2}}
http://php.net/manual/fr/function.array-merge.php
–
nicod_
liste spip
spip@rezo.net - désabonnement : envoyer un mail à spip-off@rezo.net
Archives : https://www.mail-archive.com/spip@rezo.net/maillist.html
Infos : http://listes.rezo.net/mailman/listinfo/spip
Documentation de SPIP : http://www.spip.net/
Irc : de l’aide à toute heure : http://spip.net/irc