3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$str = file_get_contents("file.csv"); $str = "sku,is_in_stock,warehouse_3,warehouse_4 AP-STYLUS,0,20,5 RC-3049,0,0,0 NFNC-FLAT-CAP,0,20,20 NFNC-HOOD14-ZIP-S,1,0,5"; $arr = explode("\n", $str); $result = array(); Foreach($arr as $line){ $linearr = explode(",", $line); If(is_numeric($linearr[2])){ if($linearr[2]+$linearr[3]>=1){ $linearr[1]="1"; $line = implode("," , $linearr); }else{ $linearr[1]="0"; $line = implode("," , $linearr); } } $result[]=$line; } $newstr = implode("\n", $result); //put_file_contents("file.csv", $newstr); Echo $newstr;
Output for git.master, git.master_jit, rfc.property-hooks
sku,is_in_stock,warehouse_3,warehouse_4 AP-STYLUS,1,20,5 RC-3049,0,0,0 NFNC-FLAT-CAP,1,20,20 NFNC-HOOD14-ZIP-S,1,0,5

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