Daily Archives: Sunday 31/01/2010

PHP: Exit a While or For Loop with Break Programming 31 JAN 2010

How do you exit or break out of a running loop before it has finished completing in PHP?

Well luckily PHP makes it pretty easy by providing us with the break control structure, a function that forces the ending of the execution of the current for, foreach, while, do-while, or switch structure.

You can extend break‘s range by utilizing its single numeric argument that tells it how many nested enclosing structures need to in fact be broken out of.

In other words, a bloody useful function to know! :)

Example Usage:

echo date('Y/m/d H:i:s') . '<br />';

The code above launches an infinite continuing loop that will print out the current time until the application is eventually forced closed. However, by inserting the break command, the date only gets echoed out once before the loop is forcefully terminated.

If this while loop had been contained within another while loop, the code as it stands would simply break out of the first while loop but continue to execute as part of the top while loop – however, if we specify break 2, the application would forcefully exit both while loops and thus finish execution.

Related Link: http://php.net/manual/en/control-structures.break.php

Cosplay Sundae: Raphael & Sophitia (Soulcalibur) Cosplay 31 JAN 2010

The Soulcalibur series, one of the best weapons-based fighting game franchises ever released and today’s Cosplay Sundae features an absolutely stunning recreation of two of the game’s prime characters, virtuous Grecian warrior Sophitia Alexandra and sinister exiled French Nobleman, Raphael Sorel. Both cosplayers have put immense time and detail into each of their respective costumes and pictures thus speak for themselves. Absolutely stunning.


For those of you not familiar with the characters, Raphael was a French nobleman exiled from his town of Rouen after committing a grievance against his family. Escaping his pursuers thanks to the help from a village girl named Amy, he slowly pieces together the mystery of the Soul Edge and embarks upon a quest to claim the evil sword for its power that will enable a better life for Amy who he has now befriended.

Sophitia on the other hand comes into contact with the Olympian god of fire and forge, Hephaestus, who tells her of the evil blade and charges her with its recovery or destruction lest it sow injustice and misery across the world. A valiant warrior and armed with the Omega Blade, Sophitia will stop at nothing to destroy the cursed Soul Edge.


Related Link: http://en.wikipedia.org/wiki/List_of_characters_in_the_Soul_series