Results 1 to 2 of 2

Thread: shorthand if/else

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default shorthand if/else

    how would i write this in shorthand?
    Code:
    <?$i = 0;?>
    foreach($datas as $row){
    ?>
    <ul class="title<? if($i % 0 {echo "0"; }else {echo "1"})?>">
    	<li></li>
    </ul>
    <? $i+=1;}?>
    something like this?
    Code:
    $i % 0 ? echo"0" : echo"1"
    Last edited by ggalan; 06-06-2011 at 01:49 PM.

  2. #2
    Join Date
    May 2011
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default

    Your very close.

    This will work.
    PHP Code:
    echo ($i%0)?"0":"1"

  3. The Following User Says Thank You to JoeDaStudd For This Useful Post:

    ggalan (06-06-2011)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •