3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $filename = '{date:Ymd:-4 day}trac{date2:Ymd:-1 day}king{date:Ymd:-1 day}'; $modifiers = array(); preg_match_all('|\{([^\}]+)\}|', $filename, $modifiers); foreach ($modifiers[1] as $id => $modifier) { $args = explode(':', $modifier); $method = array_shift($args); if ($method == 'date' && count($args)) { $replacement = count($args) == 2 ? date($args[0], strtotime($args[1])) : date($args[0]); $filename = str_replace($modifiers[0][$id], $replacement, $filename); } } echo $filename;
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
20140530trac{date2:Ymd:-1 day}king20140602