3v4l.org

run code in 300+ PHP versions simultaneously
<?php $customerProptype = (object)array ( 'first-name' => 'maria', 'last-name' => 'magdalena', 'phone-number' => 'no phone service', ); $customer = clone $customerProptype; foreach ($customer as $key => $value) { $key2 = str_replace('-', '_', $key); if ($key2 !== $key) { $customer->$key2 = $customer->$key; unset($customer->$key); } } var_export($customer, false); $customer = clone $customerProptype; foreach ($customer as $key => $value) { $key2 = str_replace('-', '_', $key); if ($key2 === $key) { continue; // nothing to do } $customer->$key2 = $customer->$key; unset($customer->$key); } var_export($customer, false); $customer = clone $customerProptype; foreach (clone $customer as $key => $value) { $key2 = str_replace('-', '_', $key); unset($customer->$key); $customer->$key2 = $value; } var_export($customer, false);
Output for git.master, git.master_jit, rfc.property-hooks
(object) array( 'first_name' => 'maria', 'last_name' => 'magdalena', 'phone_number' => 'no phone service', )(object) array( 'first_name' => 'maria', 'last_name' => 'magdalena', 'phone_number' => 'no phone service', )(object) array( 'first_name' => 'maria', 'last_name' => 'magdalena', 'phone_number' => 'no phone service', )

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:
74.36 ms | 406 KiB | 5 Q