3v4l.org

run code in 300+ PHP versions simultaneously
<?php $value = "100% Wool"; $separators = [ "/", ",", "&", " AND " ]; $value = str_replace($separators, "|", $value); $candidates = explode("|", $value); foreach($candidates as $candidate) { $percentage = (count($candidates) == 1) ? "100%" : null; if($candidate = trim($candidate)){ if(strpos("%", $candidate) !== false) { list($percentage, $material) = explode("%", $candidate); $percentage .= "%"; } else { $material = $candidate; } $entities = $this->mapping['material']; if($id = $this->exact($material, $entities)) { $material = [ 'material_id' => $id, 'percentage' => $percentage ]; $product['materials'][] = $material; } else { $this->log_errors($product, $this->dictionaries['material'], $value, 'Missing material:' . $value); } } } print_r($product['materials']);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Using $this when not in object context in /in/VXgil:23 Stack trace: #0 {main} thrown in /in/VXgil on line 23
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:
67.4 ms | 401 KiB | 8 Q