"limiting number of times a loop runs in php" Answer’s

0

If you want to use foreach, you can add an additional variable to control the number of iterations. For example:

$i=0;
foreach ($butters->users->user as $user) {
    if($i==10) break;
    $id = $user->id;
    $name = $user->screen_name;
    $profimg = $user->profile_image_url;
    echo "things";  
    $i++;  
} 
Wednesday, March 31, 2021
 
qitch
answered 11 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :