I just can't figure out what's wrong

I am doing some coding for a project. The goal is to take the first line (the header row) of a CSV file, and turn it into a multi-dimensional array.

turn CSV header row = apple, bear, cat, dog…


multi array = A1=>apple, A2 =>bear, A3 => cat, A4 => dog…
B1=>var1, B2=>var1, B3=>var1, B4=>var1…
C1=>var2, C2=>var2, C3=>var2, C4=>var2…
with some NULL values and other variable rows thrown in up to row “O”.

Here’s the code:

function put_data_into_multi_array($excelfilepath)
// Set up array to switch out CSV column letters
$cols = array(1 => “A”, 2 => “B”, 3 => “C”, 4 => “D”, 5 => “E”, 6 => “F”, 7 => “G”, 8 => “H”,
9 => “I”, 10 => “J”, 11 => “K”, 12 => “L”, 13 => “M”, 14 => “N”, 15 => “O”);

// Create new array to hold data from CSV file
$newdata_temp = array();

$i = 1;

//Create extra column variables for new multi array
$cols_b = "xxxx";
$cols_d = "yyyy";

// Set commas as default delimiter
$delimiter 	  = ","; 

if (($handle = fopen($excelfilepath, "rb")) !== false) 
	\\Pull first row of data (headers)
	$row = fgetcsv($handle, 0, $delimiter);
	// Create all columns for each single header column in $row
	for ($j = 0; $j < count($row); $j++) 
		// Add to array
		$newdata_temp[$cols[1]][$i] == $row[$j];
		$newdata_temp[$cols[2]][$i] == $cols_b;
		$newdata_temp[$cols[3]][$i] == "";		
		$newdata_temp[$cols[4]][$i] == $cols_d;
		$newdata_temp[$cols[5]][$i] == $row[$j];
		$newdata_temp[$cols[6]][$i] == "";
		$newdata_temp[$cols[7]][$i] == "";
		$newdata_temp[$cols[8]][$i] == "";
		$newdata_temp[$cols[9]][$i] == "";
		$newdata_temp[$cols[10]][$i] == "";
		$newdata_temp[$cols[11]][$i] == "";
		$newdata_temp[$cols[12]][$i] == "";
		$newdata_temp[$cols[13]][$i] == "";
		$newdata_temp[$cols[14]][$i] == "";
		$newdata_temp[$cols[15]][$i] == "";


// Return array with data dictionary values
return $newdata_temp;


I have an “include_once” at the top of the main PHP page which calls the “functions.php” file where this code is located. When the include is commented out, the main page works fine. As soon as I un-comment it, I get a totally blank browser window. No errors, no text, nothing. It’s not that complex of code, or so I thought, but I can’t even get any help from the browser on what the problem is.

I do not have a tool which debugs code. I hand code this using UltraEdit.

Any help or suggestions on anything wrong with the code would be appreciated.


when you get the blank page, look at the error log, bottom lines of it, in the www file on the server…what is the error?

Add this to the beginning of the file
[php]ini_set(‘error_reporting’, E_ALL);
ini_set(‘display_errors’, ‘1’);[/php]

then see if you get any errors instead of a blank page.

Sponsor our Newsletter | Privacy Policy | Terms of Service