Last active
June 23, 2017 21:35
-
-
Save arzola/bba3efef618da84756b3d10cbdd25ca2 to your computer and use it in GitHub Desktop.
Refactor to collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$tweets = Datostwitter::orderBy('hora', 'desc')->take(Settings::get('twitter_max'))->get(); | |
$pagetweets = []; | |
$total = count($tweets); | |
$itemtw = []; | |
for ($i = 0; $i < $total; $i+=5){ | |
for ($n = 0; $n < 5; $n++){ | |
if (isset($tweets[$i+$n])){ | |
$itemtw[$n] = $tweets[$i+$n]; | |
} | |
} | |
$pagetweets[$i] = $itemtw; | |
} | |
$this->tweets = $pagetweets; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I'm not mistaken, this will do what you need 👍