New answers tagged repeatable-field
0
Since your logos and urls exist in pairs, you can use a single loop over the logos and access the urls via the shared index.
Code: (Demo)
foreach ($jsonPartenaires['logo'] as $i => $logo) {
$html = sprintf('<img src="%s">', $logo);
if ($jsonPartenaires['url_partenaire'][$i]) {
$html = sprintf(
'<a href="%...
0
If you have only 2 arrays (URLs and logos), you can use array_combine() to create an array with one as the key and the other as value:
$data = array_combine($jsonPartenaires['url_partenaire'], $jsonPartenaires['logo']);
foreach ($data as $url => $logo) {
echo '<a href="' . $url . '"><img src="'. $logo . '"></a>';
...
Top 50 recent answers are included
Related Tags
repeatable-field × 12subform × 3
joomla-3.x × 2
custom-field × 2
jform × 2
php × 1
module × 1
articles × 1
mysql × 1
overrides × 1
joomla-3.6 × 1
form-fields-types × 1
com-content × 1
sql × 1
xml × 1
joomla-3.9 × 1
fields × 1
json × 1
com-fields × 1