3v4l.org

run code in 300+ PHP versions simultaneously
<?php if ( ! defined('PHP_EOL')) { define('PHP_EOL', chr(10)); } $string = 'Hello {{ name }}, nice to meet you.'; define('TAG_OPEN', '{{'); define('TAG_CLOSE', '}}'); define('STATE_TEXT', 'STATE_TEXT'); define('STATE_IN_TAG', 'STATE_IN_TAG'); function isOpenTag($string, $index) { return TAG_OPEN === substr($string, $index, strlen(TAG_OPEN)); } function isCloseTag($string, $index) { return TAG_CLOSE === substr($string, $index, strlen(TAG_CLOSE)); } function isText($string, $index) { return ! (isOpenTag($string, $index) || isCloseTag($string, $index)); } $state = STATE_TEXT; for($index = 0; $index < strlen($string); $index++) { if (isText($string, $index) && $state != STATE_IN_TAG) { continue; } if (isOpenTag($string, $index)) { $state = STATE_IN_TAG; $index += strlen(TAG_OPEN) - 1; continue; } if (isText($string, $index) && $state = STATE_IN_TAG) { echo $index, ' ', $string[$index], PHP_EOL; } if (isCloseTag($string, $index)) { $state = STATE_TEXT; $index += strlen(TAG_CLOSE) - 1; continue; } }
Output for git.master, git.master_jit, rfc.property-hooks
8 9 n 10 a 11 m 12 e 13

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:
51.13 ms | 401 KiB | 8 Q