3v4l.org

run code in 300+ PHP versions simultaneously
<?php $csv = <<<CSV "Price","Bogus","Symbol","Description","Qty (Quantity)","Price Chng % (Price Change %)","Price Chng $ (Price Change $)","Day Chng % (Day Change %)","Day Chng $ (Day Change $)","Cost Basis","Gain % (Gain/Loss %)","Gain $ (Gain/Loss $)","Reinvest?","Reinvest Capital Gains?","Last Div (Last Dividend)","Volume","Security Type" "$19.39","foo1","Test1","ETF","820","-2.42%","-$0.48","-2.42%","-$393.6","$601.73","-18.89%","-$3701.93","No","--","$0.72025","14,626,464","ETFs & Closed End Funds" "$49.43","foo2","Test2"," ETF","110","-2.39%","-$1.21","-2.39%","-$133.1","$995.2","-9.31%","-$557.9","Yes","--","N/A","59,351,095","ETFs & Closed End Funds" "$21.77","foo3","Test3"," ETF","760","-3.72%","-$0.84","-3.72%","-$638.4","$687.73","-20.02%","-$142.53","No","--","$2.0216","6,402,084","ETFs & Closed End Funds" CSV; $handle = tmpfile(); fwrite($handle, $csv); rewind($handle); $whitelist = [ "Symbol", "Description", "Qty (Quantity)", "Price", "Price Chng % (Price Change %)", "Price Chng $ (Price Change $)", "Day Chng % (Day Change %)", "Day Chng $ (Day Change $)", "Cost Basis", "Gain % (Gain/Loss %)", "Gain $ (Gain/Loss $)", "Reinvest?", "Reinvest Capital Gains?", "Last Div (Last Dividend)", "Volume", "Security Type" ]; $headers = fgetcsv($handle) ?: []; $map = array_flip($headers); $result = []; while (($values = fgetcsv($handle)) !== false) { $row = []; foreach ($whitelist as $col) { $row[$col] = $values[$map[$col]] ?? null; } $result[] = $row; } fclose($handle); var_export($result);
Output for git.master_jit, git.master
Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/B18lQ on line 33 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/B18lQ on line 37 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/B18lQ on line 37 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/B18lQ on line 37 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/B18lQ on line 37 array ( 0 => array ( 'Symbol' => 'Test1', 'Description' => 'ETF', 'Qty (Quantity)' => '820', 'Price' => '$19.39', 'Price Chng % (Price Change %)' => '-2.42%', 'Price Chng $ (Price Change $)' => '-$0.48', 'Day Chng % (Day Change %)' => '-2.42%', 'Day Chng $ (Day Change $)' => '-$393.6', 'Cost Basis' => '$601.73', 'Gain % (Gain/Loss %)' => '-18.89%', 'Gain $ (Gain/Loss $)' => '-$3701.93', 'Reinvest?' => 'No', 'Reinvest Capital Gains?' => '--', 'Last Div (Last Dividend)' => '$0.72025', 'Volume' => '14,626,464', 'Security Type' => 'ETFs & Closed End Funds', ), 1 => array ( 'Symbol' => 'Test2', 'Description' => ' ETF', 'Qty (Quantity)' => '110', 'Price' => '$49.43', 'Price Chng % (Price Change %)' => '-2.39%', 'Price Chng $ (Price Change $)' => '-$1.21', 'Day Chng % (Day Change %)' => '-2.39%', 'Day Chng $ (Day Change $)' => '-$133.1', 'Cost Basis' => '$995.2', 'Gain % (Gain/Loss %)' => '-9.31%', 'Gain $ (Gain/Loss $)' => '-$557.9', 'Reinvest?' => 'Yes', 'Reinvest Capital Gains?' => '--', 'Last Div (Last Dividend)' => 'N/A', 'Volume' => '59,351,095', 'Security Type' => 'ETFs & Closed End Funds', ), 2 => array ( 'Symbol' => 'Test3', 'Description' => ' ETF', 'Qty (Quantity)' => '760', 'Price' => '$21.77', 'Price Chng % (Price Change %)' => '-3.72%', 'Price Chng $ (Price Change $)' => '-$0.84', 'Day Chng % (Day Change %)' => '-3.72%', 'Day Chng $ (Day Change $)' => '-$638.4', 'Cost Basis' => '$687.73', 'Gain % (Gain/Loss %)' => '-20.02%', 'Gain $ (Gain/Loss $)' => '-$142.53', 'Reinvest?' => 'No', 'Reinvest Capital Gains?' => '--', 'Last Div (Last Dividend)' => '$2.0216', 'Volume' => '6,402,084', 'Security Type' => 'ETFs & Closed End Funds', ), )
Output for rfc.property-hooks
array ( 0 => array ( 'Symbol' => 'Test1', 'Description' => 'ETF', 'Qty (Quantity)' => '820', 'Price' => '$19.39', 'Price Chng % (Price Change %)' => '-2.42%', 'Price Chng $ (Price Change $)' => '-$0.48', 'Day Chng % (Day Change %)' => '-2.42%', 'Day Chng $ (Day Change $)' => '-$393.6', 'Cost Basis' => '$601.73', 'Gain % (Gain/Loss %)' => '-18.89%', 'Gain $ (Gain/Loss $)' => '-$3701.93', 'Reinvest?' => 'No', 'Reinvest Capital Gains?' => '--', 'Last Div (Last Dividend)' => '$0.72025', 'Volume' => '14,626,464', 'Security Type' => 'ETFs & Closed End Funds', ), 1 => array ( 'Symbol' => 'Test2', 'Description' => ' ETF', 'Qty (Quantity)' => '110', 'Price' => '$49.43', 'Price Chng % (Price Change %)' => '-2.39%', 'Price Chng $ (Price Change $)' => '-$1.21', 'Day Chng % (Day Change %)' => '-2.39%', 'Day Chng $ (Day Change $)' => '-$133.1', 'Cost Basis' => '$995.2', 'Gain % (Gain/Loss %)' => '-9.31%', 'Gain $ (Gain/Loss $)' => '-$557.9', 'Reinvest?' => 'Yes', 'Reinvest Capital Gains?' => '--', 'Last Div (Last Dividend)' => 'N/A', 'Volume' => '59,351,095', 'Security Type' => 'ETFs & Closed End Funds', ), 2 => array ( 'Symbol' => 'Test3', 'Description' => ' ETF', 'Qty (Quantity)' => '760', 'Price' => '$21.77', 'Price Chng % (Price Change %)' => '-3.72%', 'Price Chng $ (Price Change $)' => '-$0.84', 'Day Chng % (Day Change %)' => '-3.72%', 'Day Chng $ (Day Change $)' => '-$638.4', 'Cost Basis' => '$687.73', 'Gain % (Gain/Loss %)' => '-20.02%', 'Gain $ (Gain/Loss $)' => '-$142.53', 'Reinvest?' => 'No', 'Reinvest Capital Gains?' => '--', 'Last Div (Last Dividend)' => '$2.0216', 'Volume' => '6,402,084', 'Security Type' => 'ETFs & Closed End Funds', ), )

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.7 ms | 414 KiB | 5 Q