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


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

foreach ($butters->users->user as $user) {
    if($i==10) break;
    $id = $user->id;
    $name = $user->screen_name;
    $profimg = $user->profile_image_url;
    echo "things";  
Wednesday, March 31, 2021
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 :