I am using this php to parse the data and iterate over the rows but the configuration of commas and double quotes has me super confused.
Any help would be greatly appreciated.
This code I am using is breaking strings that contain commas in them.
$getDataExploded = array();
$out = "";
foreach($getData as $getDataRows)
{
$getDataExploded = explode(",",$getDataRows);
$out .= '<div id="'.$getDataExploded[4].'" class="row"><span style="font-size:14px; color:#646464;">'.$getDataExploded[0].'</span><br><span style="font-size:12px; color:#3877D9;">'.$getDataExploded[1].' / '.$getDataExploded[2].'<br><em style="font-size:11px; color:#757575;">Posted: '.$getDataExploded[3].'</em></span></div>';
}
echo($out);
Here is what the array I am trying to parse looks like…
array(29) { [0]=> string(62) “‘wefwefwef’,’ewfwefwefwef’,’wefwefwef’,1/29/2013 9:09:04 PM,37” [1]=> string(47) “‘wefwef’,’wefwefwef’,”,1/29/2013 9:08:11 PM,36″ [2]=> string(82) “‘Job Like You Never Knew’,’Sandy Hurricanes’,’Boise Idaho’,1/29/2013 9:06:12 PM,35” [3]=> string(32) “”,”,”,1/29/2013 9:04:10 PM,34″ [4]=> string(49) “‘wefwefwef’,’wfwefwef’,”,1/29/2013 9:02:05 PM,33″ [5]=> string(82) “‘Sheriff Recruitment’,’Sheriff Recruitment’,’Rhode Island’,1/28/2013 7:13:53 PM,25” [6]=> string(81) “‘Neighborhood Sales Representatives’,’Trugreen’,’Warwick’,1/28/2013 7:13:53 PM,24” [7]=> string(86) “‘Police Officer Recruitment’,’The City of Cranston’,’Cranston’,1/28/2013 7:13:53 PM,23” [8]=> string(144) “‘RNs, LPNs, CNAs, Nurse Practitioners and Physician Assistants Recruitment’,’Adil Business Systems, Inc.’,’Rhode Island’,1/28/2013 7:13:53 PM,22” [9]=> string(79) “‘Econotel EBS’,’Telecommunications Installer’,’Rumford’,1/28/2013 7:13:53 PM,21” [10]=> string(73) “‘Full-Charge Bookkeeper’,’Econotel EBS’,’Rumford’,1/28/2013 7:13:53 PM,20” [11]=> string(127) “‘Certified Nursing Assistants’,’Morning Star Home Care’,’Wakefield, Westerly, Newport and Narragansett’,1/28/2013 7:13:53 PM,19” [12]=> string(78) “‘Automobile Accountant’,’Colonial Toyota’,’Smithfield’,1/28/2013 7:13:53 PM,18” [13]=> string(89) “‘Certified Nursing Assistants’,’All About Home Care’,’Middletown’,1/28/2013 7:13:53 PM,17” [14]=> string(97) “‘Customer Development/Inside Sales’,’Hexagon Metrology’,’North Kingstown’,1/28/2013 7:13:53 PM,16” [15]=> string(85) “‘RI Sheriff’,’The RI Department of Public Safety’,’statewide’,1/28/2013 7:13:53 PM,15” [16]=> string(89) “‘Certified Nursing Assistants’,’Morning Star Home Care’,’Warwick’,1/28/2013 7:13:53 PM,14” [17]=> string(95) “‘Entry-Level Software Developers’,’Hexagon Metrology’,’North Kingstown’,1/28/2013 7:13:53 PM,13” [18]=> string(83) “‘Electronics Technician’,’Purvis Systems Inc.’,’Middletown’,1/28/2013 7:13:53 PM,12” [19]=> string(81) “‘Nurse Practitioner’,’Memorial Hospital’,’Plainville, MA’,1/28/2013 7:13:53 PM,11” [20]=> string(86) “‘Home Care Physical Therapist’,’Memorial Hospital’,’Pawtucket’,1/28/2013 7:13:53 PM,10” [21]=> string(87) “‘Real Estate Specialist’,’Linear Title and Closing’,’Middletown’,1/28/2013 7:13:53 PM,9” [22]=> string(77) “‘Equipment Technician’,’Angelica Textiles’,’Pawtucket’,1/28/2013 7:13:53 PM,8” [23]=> string(68) “‘Painting Crew Leader’,’LOPCO’,’Rhode Island’,1/28/2013 7:13:53 PM,7” [24]=> string(102) “‘Diesel Mechanic’,’Interstate Diesel Equipment Service, Inc.’,’North Kingstown’,1/28/2013 7:13:53 PM,6” [25]=> string(73) “‘Hydromat Machine Operators’,’Greystone’,’Lincoln’,1/28/2013 7:13:53 PM,5” [26]=> string(85) “‘National Sales Manager’,’Hexagon Metrology’,’North Kingstown’,1/28/2013 7:13:53 PM,4” [27]=> string(131) “‘North Providence Probationary Police Officer Recruitment’,’The Town of North Providence’,’North Providence’,1/28/2013 7:13:53 PM,3” [28]=> string(113) “‘Territory Service Representatives’,’Scotts Lawn Service’,’Rhode Island and Massachusetts’,1/28/2013 7:13:53 PM,2” }
PHP provides a
str_getcsv()method which you may find useful. It stops you needing to worry as much about commas and text delimiters.Edit: Changed use of htmlentities as pointed out by jeroen