samedi 23 janvier 2021

How to get string items with exponential increase index locations

How to get string items within index locations 1,2,8,9,15,16 (covid,1234,sars,2345,ebv,2345).

$str2 = "false|covid|1234|yes|no|no|556|true|sars|2345|no|no|yes|235|true|ebv|2345|no|no|yes|235";

$var2=explode('|',$str2);

$leg = -7;
$lag = -4;
foreach($var2 as $key => $row2){
$leg = $leg + 7;
$lag = $lag + 7;


if($key > $leg && $key < $lag){

echo $row2.",";
}

}

Aucun commentaire:

Enregistrer un commentaire