Skip to content

A nice PHP Utility made out of boredom for encoding a string into brainfuck code and vice-versa.

License

Notifications You must be signed in to change notification settings

rumd3x/php-brainfuck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-brainfuck

A nice PHP Utility made out of boredom for encoding a string into brainfuck code and vice-versa.

Installation

To install via composer just run

  composer require rumd3x/php-brainfuck

Usage

Encoding

use Rumd3x\Brainfuck\Brainfuck;

echo Brainfuck::encode("Hello World!"); 
// outputs: ++++++++++[>+++++++>++++++++++>+++++++++++>+++++++++++>+++++++++++>+++>+++++++++>+++++++++++>+++++++++++>+++++++++++>++++++++++>+++<<<<<<<<<<<<-]>++.>+.>--.>--.>+.>++.>---.>+.>++++.>--.>.>+++.

There's also a second a third optional parameters for the encoding.

The second is for replacing non-ASCII characters.

And the third is for generating an minified or pretty-printed version of the code.

use Rumd3x\Brainfuck\Brainfuck;

echo Brainfuck::encode("Some ASCII: ABC+ŤĎ and some non-ASCII: Ąąśćł.'", true); // will replace non-ascii with their ascii counterpart 
echo Brainfuck::encode("Prettifying'", false, true); // will output pretty printed brainfuck code

Decoding

use Rumd3x\Brainfuck\Brainfuck;

echo Brainfuck::decode("++++++++++[>+++++++>++++++++++>+++++++++++>+++++++++++>+++++++++++>+++>+++++++++>+++++++++++>+++++++++++>+++++++++++>++++++++++>+++<<<<<<<<<<<<-]>++.>+.>--.>--.>+.>++.>---.>+.>++++.>--.>.>+++."); 
// outputs: Hello World!

Happy brainfucking!

About

A nice PHP Utility made out of boredom for encoding a string into brainfuck code and vice-versa.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages