@ 2015-12-23T15:27:45Z <?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 {
}
}
}
print_r($product['materials']);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.20 , 7.2.0 - 7.2.33 , 7.3.16 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.27 , 8.2.0 - 8.2.17 , 8.3.0 - 8.3.4 Fatal error: Uncaught Error: Using $this when not in object context in /in/NkHBc:22
Stack trace:
#0 {main}
thrown in /in/NkHBc on line 22
Process exited with code 255 . Output for 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 Fatal error: Using $this when not in object context in /in/NkHBc on line 22
Process exited with code 255 . preferences:dark mode live preview
167.12 ms | 401 KiB | 179 Q