New answers tagged

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