private function serialiseTheArrayKey($arr, $myName, &$headingRow, &$dataRow) { $ret = ""; foreach ($arr as $k => $val) { $ret = $myName; $dk = ArrayBuilder::getDummyKey(); if ($k != $dk) { $ret .= "_" . $k; } if (is_array($val)) { $this->serialiseTheArrayKey($val, $ret, $headingRow, $dataRow); } else { $headingRow[$ret] = true; $dataRow[$ret] = $val; } } }
public static function convertFileToArray($file, $inputFormat) { $ret = array(); //always return array no undefine notices will be generated then.. if (ArrayBuilder::verifyFileAndExtension($file)) { $fileExtension = ""; if (isset($inputFormat) && !empty($inputFormat)) { $fileExtension = $inputFormat; } else { $fileName = basename($file); $fileExtension = substr($fileName, strrpos($fileName, ".") + 1); } switch (strtolower($fileExtension)) { case "csv": $ret = ArrayBuilder::convertCSVToArray($file); break; case "js": $ret = ArrayBuilder::convertJSONToArray($file); break; case "xml": $ret = ArrayBuilder::convertXMLToArray($file); break; default: print "We don't support yet {$fileExtension}."; exit; } } else { $allSuppFile = SupportedFileType::getAllSupportedType(); if (count($allSuppFile) > 0) { $str = implode(",", $allSuppFile); print "Supported files are: {$str}"; exit; } } return $ret; }
public function setParams($params) { return parent::setParams(json_decode($params, true)); }
public function __construct() { $this->dummyKey = ArrayBuilder::getDummyKey(); }
private function convertFileToArray() { $this->arrayOfElements = ArrayBuilder::convertFileToArray($this->file, $this->inputFormat); }