3v4l.org

run code in 300+ PHP versions simultaneously
<?php function format_array($pattern, array $array) { return array_map( function (array $data) use ($pattern) { return preg_replace_callback( '/\{(\w+)\}/', function (array $match) use ($data) { return $data[$match[1]]; }, $pattern ); }, $array ); } $array = array( 1 => array( 'quote' => 'To be or not to be', 'citation' => 'Hamlet' ), 2 => array( 'quote' => 'The left hand knows that the right hand is doing', 'citation' => 'President Bush' ), 3 => array( 'quote' => 'Another quote', 'citation' => 'Another person' ) ); $array = format_array('{quote} – {citation}', $array); print_r($array);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [1] => To be or not to be – Hamlet [2] => The left hand knows that the right hand is doing – President Bush [3] => Another quote – Another person )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.11 ms | 401 KiB | 8 Q