Of course, here is one way to do this. It takes a bit of love though, and PHP 5.3+
<?php $subject = array( 'id' => '{{product-id}}' ); $values = array( 'product-id' => 1 ); array_walk($subject, function( & $item) use ($values) { foreach($values as $template => $value) { $item = str_replace( sprintf('{{%s}}', $template), $value, $item ); } }); var_dump( $subject );
source share