On Fri, 2011-09-09 at 16:00 +0000, Marc Fromm wrote:
> I am reading a csv file into an array. The csv file.
> 
> users.csv file contents:
> w12345678,a
> w23456789,b
> w34567890,c
> 
>                                 $csvfilename = "users.csv";
> $handle = fopen($csvfilename, "r");
>                                 if($handle) {
>                                                 while (($line = 
> fgetcsv($handle, 1000, ",")) !== FALSE) {
>                                                                 $arrUsers[] = 
> $line;
>                                                 }
>                                                 fclose($handle);
>                                 }
> 
> When I echo out the elements in the elements in the array $arrUsers I get:
> Array
> Array
> Array
> 
> foreach ($arrUsers as $user){
>                 echo $user . "<br />";
> }
> 
> I can't figure out why the word Array is replacing the actual data.
> 

Try print_r($arrUsers);

also, the $line is an array of the CSV, so you're storing an array,
within the array $arrUsers.

foreach ($arrUsers as $user){
        foreach ($user as $val) {
                echo $val . "<br />";
        }
        echo '<hr />';
}


-- 

Steve Staples
Web Application Developer
519.258.2333 x8414


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to