3v4l.org

run code in 300+ PHP versions simultaneously
<?php $userdata = 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); var_dump($userdata);
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 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.18, 8.3.0 - 8.3.4, 8.3.6
array(9) { [0]=> string(21) "Industry Organization" [1]=> string(25) "Technical Staffing Agency" [2]=> string(5) "Other" [3]=> string(31) "Contract Manufacturing Services" [4]=> string(20) "Engineering Services" [5]=> string(30) "Technical Sales Representative" [6]=> string(16) "Testing Services" [7]=> string(6) "Labels" [8]=> string(28) "Marketing Materials Provider" } array(31) { ["firstName"]=> string(5) "Blake" ["lastName"]=> string(6) "Patton" ["title"]=> string(3) "Dev" ["companyName"]=> string(7) "Example" ["companyLocation"]=> string(5) "Idaho" ["email"]=> string(17) "lorem@example.com" ["website"]=> string(0) "" ["address_1"]=> string(12) "123 Fake St." ["address_2"]=> string(0) "" ["addressCity"]=> string(9) "Fakeville" ["addressState"]=> string(2) "WA" ["addressZipcode"]=> string(6) "123456" ["phone"]=> string(12) "123-456-1234" ["fax"]=> string(0) "" ["companyDescription"]=> string(0) "" ["checkIndustryOrganization"]=> string(2) "on" ["checkTechnicalStaffingAgency"]=> string(2) "on" ["checkOther"]=> string(2) "on" ["addlBiz"]=> string(1) "1" ["addEntry"]=> string(1) "1" ["addDescription"]=> string(13) "Ipsm Sit Imut" ["addWebsite"]=> string(0) "" ["checkContractManufacturingServices"]=> string(2) "on" ["checkEngineeringServices"]=> string(2) "on" ["checkTechnicalSalesRepresentative"]=> string(2) "on" ["checkTestingServices"]=> string(2) "on" ["checkLabels"]=> string(2) "on" ["checkMarketingMaterialsProvider"]=> string(2) "on" ["table1"]=> string(2) "35" ["table2"]=> string(2) "36" ["paypal_token"]=> string(20) "EC-9RS395813D9318137" }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array(9) { [0]=> string(21) "Industry Organization" [1]=> string(25) "Technical Staffing Agency" [2]=> string(5) "Other" [3]=> string(31) "Contract Manufacturing Services" [4]=> string(20) "Engineering Services" [5]=> string(30) "Technical Sales Representative" [6]=> string(16) "Testing Services" [7]=> string(6) "Labels" [8]=> string(28) "Marketing Materials Provider" } array(31) { ["firstName"]=> string(5) "Blake" ["lastName"]=> string(6) "Patton" ["title"]=> string(3) "Dev" ["companyName"]=> string(7) "Example" ["companyLocation"]=> string(5) "Idaho" ["email"]=> string(17) "lorem@example.com" ["website"]=> string(0) "" ["address_1"]=> string(12) "123 Fake St." ["address_2"]=> string(0) "" ["addressCity"]=> string(9) "Fakeville" ["addressState"]=> string(2) "WA" ["addressZipcode"]=> string(6) "123456" ["phone"]=> string(12) "123-456-1234" ["fax"]=> string(0) "" ["companyDescription"]=> string(0) "" ["checkIndustryOrganization"]=> string(2) "on" ["checkTechnicalStaffingAgency"]=> string(2) "on" ["checkOther"]=> string(2) "on" ["addlBiz"]=> string(1) "1" ["addEntry"]=> string(1) "1" ["addDescription"]=> string(13) "Ipsm Sit Imut" ["addWebsite"]=> string(0) "" ["checkContractManufacturingServices"]=> string(2) "on" ["checkEngineeringServices"]=> string(2) "on" ["checkTechnicalSalesRepresentative"]=> string(2) "on" ["checkTestingServices"]=> string(2) "on" ["checkLabels"]=> string(2) "on" ["checkMarketingMaterialsProvider"]=> string(2) "on" ["table1"]=> string(2) "35" ["table2"]=> string(2) "36" ["paypal_token"]=> string(20) "EC-9RS395813D9318137" }

preferences:
262.56 ms | 409 KiB | 341 Q