Skip to content

Instantly share code, notes, and snippets.

@hultberg
Created April 24, 2017 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hultberg/23f89f7c476c6db3ad6477dc5bedbfd3 to your computer and use it in GitHub Desktop.
Save hultberg/23f89f7c476c6db3ad6477dc5bedbfd3 to your computer and use it in GitHub Desktop.
<?php
function compile($data) {
// Compile variables:
// var = $value
//
// into:
// $var = $value
$data = preg_replace('/[a-Z]/im', '');
// Compile:
// if $cond
//
// into:
// if ($cond) {
$data = preg_replace('/if (.*)/im', 'if ($1) {', $data);
return $data;
}
echo compile('if value == 1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment