3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testHeader = ['Mold SKU', 'Title', 'Category', 'Tags']; $testRows = []; $testRows[] = ['12MM-SM-SQ', '12mm Squares', 'Earings|Earings > Fishhooks','square']; $testRows[] = ['12MM-SQ-HOLLOW-DROP', 'Square Hollow Drop Studs', 'Earings|Earings > Studs','square']; $testRows[] = ['Example SKU', 'Example Title', 'Example|Sub|Whatever|category','tag1|tag2|tag3']; $testArray = [$testHeader, ...$testRows]; $fp = fopen('php://memory', 'w+'); foreach ($testArray as $testRow) { fputcsv($fp, $testRow); } rewind($fp); // ABOVE IS ONLY FOR TESTING HERE! ------------------------------------- // $fp = fopen($skufileurl, 'r'); // <-- you will use this! $termName = 'Example SKU'; $csvRows = []; $csvHeader = fgetcsv($fp); while ($csvRow = fgetcsv($fp)) { $keyedCsvRow = array_combine($csvHeader, $csvRow); if ($keyedCsvRow['Mold SKU'] === $termName) { $keyedCsvRow['Category'] = explode('|', $keyedCsvRow['Category']); $keyedCsvRow['Tags'] = explode('|', $keyedCsvRow['Tags']); $finalArray = $keyedCsvRow; break; } } var_dump($finalArray);
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { ["Mold SKU"]=> string(11) "Example SKU" ["Title"]=> string(13) "Example Title" ["Category"]=> array(4) { [0]=> string(7) "Example" [1]=> string(3) "Sub" [2]=> string(8) "Whatever" [3]=> string(8) "category" } ["Tags"]=> array(3) { [0]=> string(4) "tag1" [1]=> string(4) "tag2" [2]=> string(4) "tag3" } }

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