mardi 22 décembre 2020

get value 1 - 2 - 1 - 2 - 1 in for loop php

I am trying to get value like 1-2-1-2-1-2 from for loop

I tried code like this

$c = count($response['video']); // 2
$currentPage  = 2;
$k = 1;
for ($i=$k; $i <= $currentPage ; $i++) {
    $b = $i > $c ? $k : $i;
    $urls = $response['video'][$b - 1];
    echo "$b";
}

where $currentPage = 5; $c =2;

when $c = 3; the value should be 1-2-3-1-2-3 when i echo $b or dd($b) out of loop i will got 12111 but i need answer 121212 please help me to solve this.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/38rbYfr
via IFTTT

Aucun commentaire:

Enregistrer un commentaire