An experimental library that lets you create PHP arrays in a more aesthetic manner
Switch branches/tags
Nothing to show
Pull request Compare This branch is even with juliend2:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



“One whose pursuit and admiration of beauty is regarded as excessive or affected.”

Aesthete.php is an experimental library that lets you create arrays in a more “aesthetic” manner.
Returned arrays descend from the ArrayObject SPL class. Which is nice because it lets you add some methods, such as each().


First, require it:


Now, lets say i want to create an array of string. Simple. In Ruby i would do it like this:

%w( my array of words )

But PHP’s array() syntax is kinda verbose for such a simple array:

array('my', 'array', 'of', 'words')

With Aesthete.php, you can create an array of words like this instead:

w(' my array of words ')

Then you can loop into it like this. For FREE! :

w(' this is an array of words ')->each(function($w){
  echo "{$w}<br/>";

Or you can create an array of any types and loop into it:

a('one', 'two', 3, 4)->each(function($thing){
  echo "{$thing}<br/>";

Or a hash of strings and loop into it:

 key            = value
 another        = string
 number         = 23
 a_long_string  = this is a long string
")->each(function($k, $v){
  echo "{$k} => {$v}<br/>";

See test/tests.php and examples/* for more usage examples.

Minimum requirements

You’ll need to have PHP >5.3 because of the AestheteHash and AestheteArray’s each methods that takes an anonymous function.

Special Thanks

Thanks to Alexandre Gomes Gaigalas for suggesting the use of parse_ini_string() for parsing the h() function’s argument. Awesome stuff are possible now.