3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $var = unserialize('a:31:{s:9:"firstName";s:5:"Blake";s:8:"lastName";s:6:"Patton";s:5:"title";s:3:"Dev";s:11:"companyName";s:7:"Example";s:15:"companyLocation";s:5:"Idaho";s:5:"email";s:17:"lorem@example.com";s:7:"website";s:0:"";s:9:"address_1";s:12:"123 Fake St.";s:9:"address_2";s:0:"";s:11:"addressCity";s:9:"Fakeville";s:12:"addressState";s:2:"WA";s:14:"addressZipcode";s:6:"123456";s:5:"phone";s:12:"123-456-1234";s:3:"fax";s:0:"";s:18:"companyDescription";s:0:"";s:25:"checkIndustryOrganization";s:2:"on";s:28:"checkTechnicalStaffingAgency";s:2:"on";s:10:"checkOther";s:2:"on";s:7:"addlBiz";s:1:"1";s:8:"addEntry";s:1:"1";s:14:"addDescription";s:13:"Ipsm Sit Imut";s:10:"addWebsite";s:0:"";s:34:"checkContractManufacturingServices";s:2:"on";s:24:"checkEngineeringServices";s:2:"on";s:33:"checkTechnicalSalesRepresentative";s:2:"on";s:20:"checkTestingServices";s:2:"on";s:11:"checkLabels";s:2:"on";s:31:"checkMarketingMaterialsProvider";s:2:"on";s:6:"table1";s:2:"35";s:6:"table2";s:2:"36";s:12:"paypal_token";s:20:"EC-9RS395813D9318137";}'); foreach($userdata as $key=>$val){ $split = preg_split('/(?=[A-Z])/',$key); if($split[0]=='check'){ if($val == 'on'){ $category = ''; foreach($split as $name){ if($name!='check'){ $category .= $name.' '; } } $categories[]=trim($category); } } unset($split, $name, $key, $val, $category); } var_dump($categories);
Output for 5.1.0 - 7.1.0
Notice: Undefined variable: userdata in /in/LjLDZ on line 3 Warning: Invalid argument supplied for foreach() in /in/LjLDZ on line 3 Notice: Undefined variable: categories in /in/LjLDZ on line 19 NULL
Output for 5.0.4 - 5.0.5
Warning: Invalid argument supplied for foreach() in /in/LjLDZ on line 3 Notice: Undefined variable: categories in /in/LjLDZ on line 19 NULL
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.0.3
Warning: Invalid argument supplied for foreach() in /in/LjLDZ on line 3 Notice: Undefined variable: categories in /in/LjLDZ on line 19 NULL
Output for 4.3.11
Notice: Undefined variable: categories in /in/LjLDZ on line 19 NULL