php loop through string

34

//Split int char array
$chars = str_split($str);

//Loop each char
foreach($chars as $char)
{
    // your code
}
// Step 1: convert the string to an array using the str_split function

$array = str_split($your_string);

// Step 2: loop through the newly created array

foreach ($array as $char) {
 echo $char;
}
<?php
 
$scores = [1,2,3];
foreach ($scores as $score) {
 echo $score;
}

Comments

Submit
0 Comments