Jump to content

applelover

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Posts posted by applelover

  1. Ok, following is the code for placing ordinal suffixes to certain variables and so I'm trying to understand how it works.

     

    $test_c = abs($ranking) % 10;

    $ranking_suffix = ((abs($ranking) %100 <21> 4) ? 'th' : (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1)

                ? 'th' : 'st' : 'nd' : 'rd' : 'th'));

     

    Basically, its taking the value of $ranking and making it absolute but I've no idea what % 10, % 100, <21> 4 means.

     

    Then it runs several conditions to test this variable and assigning the relevant suffixes. 

     

    How do these conditions work? ie. what does the first part preceding  ":" do and if ($test_c < 4) what happens?

     

    Thanks for your guidance.

  2. No thank you poco for posting a solution so fast!  Actually I can follow your code more easily as I'm not familiar with php functions.

     

    And thanks to Sasa as well for posting another solution, so advanced :-)

     

    Both code works and did what I wanted to do.

  3. I have a string that I wish to divide into 100 words per part so that each part can be displayed on the page separately.

     

    ie. $text = "The quick brown fox jumps over the lazy dog (x 100 times)"

     

    How do I split this text into an array 100 words at a time?

     

    Thanks.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.