<?php
function format() {
return null;
}
if (count($args) === 1) { return $args[0];
}
}
Uso:
$str = 'Meu nome eh {1}.
Sim, o meu nome eh {1}.
Eu tenho {2} anos de idade.
{1} {2} {2} {1}';
echo format($str, 'Wallace', 26);
PD9waHAKICAgIGZ1bmN0aW9uIGZvcm1hdCgpIHsKICAgICAgICAkYXJncyA9IGZ1bmNfZ2V0X2FyZ3MoKTsKICAgICAgICBpZiAoZW1wdHkoJGFyZ3MpKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgIAogICAgICAgIGlmIChjb3VudCgkYXJncykgPT09IDEpIHsKICAgICAgICAgICAgcmV0dXJuICRhcmdzWzBdOwogICAgICAgIH0KICAgIAogICAgICAgICRzdHIgPSBhcnJheV9zaGlmdCgkYXJncyk7CiAgICAgICAgJHN0ciA9IHByZWdfcmVwbGFjZSgnI1x7KFxkKylcfSMnLCAnJSQxXCRzJywgJHN0cik7CgogICAgICAgIHJldHVybiB2c3ByaW50Zigkc3RyLCAkYXJncyk7CiAgICB9CgpVc286CgogICAgJHN0ciA9ICdNZXUgbm9tZSBlaCB7MX0uCiAgICAgICAgICAgIFNpbSwgbyBtZXUgbm9tZSBlaCB7MX0uCiAgICAgICAgICAgIEV1IHRlbmhvIHsyfSBhbm9zIGRlIGlkYWRlLgogICAgICAgICAgICB7MX0gezJ9IHsyfSB7MX0nOwoKICAgIGVjaG8gZm9ybWF0KCRzdHIsICdXYWxsYWNlJywgMjYpOw==