3v4l.org

run code in 300+ PHP versions simultaneously
<?php $code = <<<TWIG (function (Translator) { {% if include_config %} Translator.fallback = '{{ fallback }}'; Translator.defaultDomain = '{{ defaultDomain }}'; {% endif %} {% for locale, domains in translations %} // {{ locale }} {% for domain, messages in domains %} {% for key, message in messages %} Translator.add({{ key|json_encode|raw }}, {{ message|json_encode|raw }}, "{{ domain }}", "{{ locale }}"); {% endfor %} {% endfor %} {% endfor %} })(Translator); TWIG; preg_match_all('/(\{\{|\{%|\{\#)(\-)?/s', $code, $matches, PREG_OFFSET_CAPTURE); var_dump($matches[2]);
Output for 7.4.0 - 7.4.23, 8.0.0 - 8.0.11, 8.1rc1 - rc2
array(15) { [0]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [1]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [2]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [3]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [4]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [5]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [6]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [7]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [8]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [9]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [10]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [11]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [12]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [13]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } [14]=> array(2) { [0]=> string(0) "" [1]=> int(-1) } }
Output for 4.3.3 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.30
array(15) { [0]=> string(0) "" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(0) "" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" [12]=> string(0) "" [13]=> string(0) "" [14]=> string(0) "" }
Output for 4.3.1 - 4.3.2
Warning: Wrong value for parameter 4 in call to preg_match_all() in /in/lvdlR on line 20 NULL

preferences:
38.41 ms | 462 KiB | 5 Q