Show divs based on the amount of arrays

后端 未结 2 1801
醉话见心
醉话见心 2021-01-20 14:43

Here is my function

function yyy_hero_image_option_callback() {
$hero_options = get_option( \'hero_options\' ); 
$count=count($hero_options);
$totalimg=$coun         


        
2条回答
  •  情话喂你
    2021-01-20 15:09

    The way you changed your code, $i is not set anymore, try this :

    foreach ($hero_options as $key => $value) {
        if (strpos($key, '_zzz_')) {
            $i = substr($key, -1); // This will retrieve the last char of $key, which is corresponding to your previous $i
            $html = '
    '; $html .= '
    '; $html .= '
    -
    '; $html .= '
    '; $html .= '
    '; echo $html; } }

    I also replaced the $hero_options[key] parts by $value, since you already get it from the foreach.

提交回复
热议问题