I was struggling with how to convert a long two-column (A and B) Excel data set into a PHP associative array format and then found out how easy is this with the CHAR() built-in function. This is what I did.

1. For the data in the A1 and B1 cells, I simply entered the following formula into the C1 cell and bingo!


where the unicode numbers 34, 61, 62, and 44 are used to render the double quote, equality, greater than, and comma symbols.

2. Then I just pasted the formula in the remaining cells of column C.

3. Finally, I pasted the result into a php text file, between the parentheses of

$arr=array(  );

and removed the last comma from the last array element.

I know there is an easier way by writing a short macro, but this worked for me just fine.

I hope this saves some time to others.

About these ads