Anonymous Inner (Lambda) Functions with PHP

<?php
$str = "hello world!";


/* 1. won't work with with anonymous inner (lambda) function before PHP 5.3
  $str = preg_replace_callback(
    '/world/',
    function( '$match', 'return "michael";' ),
    $str ); */
 

/* 2. use create_function instead */
$str = preg_replace_callback(
  '/world/',
  create_function( '$match', 'return "michael";' ),
  $str );
 

echo $str ; // output: hello michael!
?>