toolman Posted August 1, 2012 Share Posted August 1, 2012 Hi, I have some divs that are created automatically, but I am giving the divs a margin-right, which means the last div is breaking onto a new line. Is there a way I can give the last div it's own class? Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 1, 2012 Share Posted August 1, 2012 Yes. Were you wanting more help? Posting some code might help us to do that. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 1, 2012 Share Posted August 1, 2012 Here is a very rudimentary example //Create function to output one DIV of content for a record function displayContent($value, $class) { echo "<div class='{$class}'>{$value}</div>\n"; } //Loop through records to be displayed foreach($arrayOfData as $recordID => $value) { if(isset($prevValue)) { //Create output for previous value/record //Using selected class/style displayContent($prevValue, 'alignRight'); } $prevValue = $value; } //Create output for very last record using a different class displayContent($lastValue, 'alignLeft'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.