Rating:

# PHP Golf

## Problem

Johnny B. Krad from your local schoolyard gang still thinks that you are a poser! Even if you could beat him in Perl golf, you probably can't in PHP golf...

[Link](https://school.fluxfingers.net:1521/golf/php/)

## Solution

Credit: [@emedvedev](https://github.com/emedvedev), [@johndearman](https://github.com/johndearman)

This is a sequel to the [Perl Golf](../Perl Golf [ppc] (75)/) challenge from the same CTF with considerably less solves. Let's open the link:

> Write a PHP program that takes a parameter as input and outputs a filtered version with alternating upper/lower case letters of the (english) alphabet. Non-letter characters have to be printed but otherwise ignored.
>
> - You have 1 second.
> - You have 62 (ASCII) chars.
> - Do not flood the server.
>
> ```
> Input Hello World! Hallo Welt!
> Output HeLlO wOrLd! HaLlO wElT!
> ```

A common approach to this challenge was piping the input through the previously obtained script from Perl Golf, which is hilarious. However, let's try a "clear" PHP-only approach.

We'll write a script similar to the Perl challenge: match every letter with a regex and iterate a counter, alternating uppercase and lowercase:

```

Original writeup (https://github.com/RandomsCTF/write-ups/tree/master/Hack.lu%20CTF%202015/PHP%20Golf%20%5Bppc%5D%20(75)).