3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fileData = '$orange="100kg";$Apple="400kg";$Peach="543kg";'; $patternVars = '/(?<=\$).*?(?=\=)/m'; $patternValues = '/(?<="(?!;)).*?(?=")/m'; $vars = preg_match_all($patternVars, $fileData, $varMatches); // Match all variables $values = preg_match_all($patternValues, $fileData, $valueMatches); // Match all values forEach($varMatches[0] as $key => $value){ // Use the value to name your variable (hence the weird looking "$$") and set the value of this variable to the matches of your values. $$value = $valueMatches[0][$key]; } var_dump($orange); // Will output "100kg"
Output for git.master, git.master_jit, rfc.property-hooks
string(5) "100kg"

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:
40.07 ms | 1242 KiB | 4 Q