3v4l.org

run code in 300+ PHP versions simultaneously
<?php $controlValue = [ 'item1' => 'val1', 'item2' => 'val2', 'item3' => [ 'item4' => 'val4', 'item5' => 'val5', ], ]; $encryptedFields = [ 'item2', 'item3.item5', ]; foreach ($encryptedFields as $encryptedField) { if (strpos($encryptedField, '.') !== false) { $encryptedFieldSegments = explode('.', $encryptedField); $encryptedFieldSegment = array_shift($encryptedFieldSegments); if (!isset($controlValue[$encryptedFieldSegment])) { continue; } $valueReference = &$controlValue[$encryptedFieldSegment]; foreach ($encryptedFieldSegments as $encryptedFieldSegment) { if (!isset($valueReference[$encryptedFieldSegment])) { break; } $valueReference = &$valueReference[$encryptedFieldSegment]; $vaultCiphertext = strrev($valueReference[$encryptedField]); $valueReference[$encryptedField] = $vaultCiphertext; } unset($valueReference); } elseif (isset($controlValue[$encryptedField])) { $vaultCiphertext = strrev($controlValue[$encryptedField]); $controlValue[$encryptedField] = $vaultCiphertext; } } var_dump($controlValue);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/VODih:33 Stack trace: #0 {main} thrown in /in/VODih on line 33
Process exited with code 255.

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