applelover
-
Posts
3 -
Joined
-
Last visited
Never
Posts posted by applelover
-
-
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.
-
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.
Please explain how this code works
in PHP Coding Help
Posted
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.