Created
June 13, 2017 07:48
-
-
Save TakesTheBiscuit/919180409ed2ad3f791690e41490cb67 to your computer and use it in GitHub Desktop.
For Ando
This file contains hidden or 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
<?php | |
// just because this isn't wordpress.. | |
$dummy_post = array('title'=>'the post name', 'body'=>'some post content'); | |
$posts = array($dummy_post ,$dummy_post ,$dummy_post,$dummy_post,$dummy_post,$dummy_post ); | |
$track_count = 0; | |
$posts_output = []; | |
foreach ($posts as $index => $post) { | |
$this_class = ''; | |
switch ($track_count) { | |
case 0: | |
$this_class = 'classONE'; | |
break; | |
case 1: | |
$this_class = 'classTWO'; | |
break; | |
case 2: | |
$this_class = 'classTHREE'; | |
break; | |
case 3: | |
$this_class = 'classFOUR'; | |
break; | |
} | |
$post['className'] = $this_class; | |
$posts_output[$index] = $post; | |
if ($track_count == 3) { | |
$track_count = 0; | |
} else { | |
$track_count++; | |
} | |
} | |
// see it , to use it: look for 'className' inside your next posts output loop | |
print_r($posts_output); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment