note 112152 added to language.oop5

From: Date: Fri, 10 May 2013 09:31:40 +0000
Subject: note 112152 added to language.oop5
Groups: php.notes 
Request: Send a blank email to php-notes+get-194763@lists.php.net to get a copy of this message
<?php /** * Description of bscsvarray class for array to csv and csv to array convert * @author Md.Hafizur Rahman */ class bscsvarray { var $csvtoarray_tmp_file_name; var $csvtoarray_buffer; var $csvtoarraystr=array(); var $csvtoarrayresult=array(); var $arraytocsv_buffer; public function __construct() { $this->csvtoarray_tmp_file_name=''; $this->arraytocsv_buffer=''; $this->csvtoarray_buffer=''; } public function csvtoarray($fname) //CSV file-> Multi Dimentional Aaary { if (($this->csvtoarray_tmp_file_name = fopen($fname, "r")) !== FALSE) { while (($this->csvtoarray_buffer = fgetcsv($this->csvtoarray_tmp_file_name,100000, ",")) !== FALSE) { $this->csvtoarraystr=array(); foreach ($this->csvtoarray_buffer as $value) { array_push($this->csvtoarraystr,$value); } array_push($this->csvtoarrayresult,$this->csvtoarraystr); } fclose($this->csvtoarray_tmp_file_name); } return $this->csvtoarrayresult; } public function arraytocsv($fname,$list=array()) //Multi Dimentional Aaary ->CSV file { if(($this->arraytocsv_buffer = fopen($fname, 'w'))!== FALSE ) { foreach ($list as $fields) { fputcsv($this->arraytocsv_buffer, $fields); } fclose($this->arraytocsv_buffer); } } public function __destruct() { return 0; } } $file=new bscsvarray(); $file->csvtoarray('test.csv'); // return array $list=array( array('ID','NAME','ADDRESS'),array('ID001','Hafiz','Bangladesh')); $file->arraytocsv('xyz.csv',$list); // return csv file ?> ---- Server IP: 69.147.83.199 Probable Submitter: 180.149.25.87 ---- Manual Page -- http://php.net/manual/en/language.oop5.php Edit -- https://master.php.net/note/edit/112152 Del: integrated -- https://master.php.net/note/delete/112152/integrated Del: useless -- https://master.php.net/note/delete/112152/useless Del: bad code -- https://master.php.net/note/delete/112152/bad+code Del: spam -- https://master.php.net/note/delete/112152/spam Del: non-english -- https://master.php.net/note/delete/112152/non-english Del: in docs -- https://master.php.net/note/delete/112152/in+docs Del: other reasons-- https://master.php.net/note/delete/112152 Reject -- https://master.php.net/note/reject/112152 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194763) next »