Don't understand this conditional statement..

Posted on 2011-04-20
Last Modified: 2012-05-11
in a WP plug-in

if ( $gallery->columns > 0 && ++$i % $gallery->columns == 0 )

I don't understand the syntax...
Question by:chrisfixit
    LVL 14

    Accepted Solution

    If the amount of columns in the gallery is greater than 0 and a counter $i that is being increased by one before the calculation is dividable by the amount of columns with no modulo...
    LVL 4

    Expert Comment

    It says if the result of the comparison of ($gallery-> columns greater than zero AND the (modulus of incremented $i divided by $gallery->columns)) is equal to zero
    LVL 48

    Expert Comment


    $gallery->columns > 0
    colums is greater than 0

    ++$i % $gallery->columns == 0
    ((increased loopcounter $i by one ) modulo the columns) is zero

    typical means to make a column break if the number of elments in the row has reached the number of columns to display

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to count occurrences of each item in an array.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now