/** * {@inheritdoc} * * Target format: CSV * * <code> * $options = [ * 'delimiter' => ',', // typically ,|;|\t * 'enclosure' => '"', // typically "|' * 'escape' => '\\', // how the above is escaped * 'pivot' => false // pivot resulting array * ]; * </code> * @example url://path/to/example.php description * * @param mixed $resource * @param array $options * @return array */ public function toArray($resource, array $options = []) { $options = array_merge(['delimiter' => ',', 'enclosure' => '"', 'escape' => '\\', 'pivot' => false], $options); $resource = explode("\n", trim(parent::getRealResource($resource, $options))); $retval = []; foreach ($resource as $line) { $line = trim($line); $values = str_getcsv($line, $options['delimiter'], $options['enclosure'], $options['escape']); $retval[] = ArrayUtils::typecast($values); } return $options['pivot'] ? ArrayUtils::pivot($retval) : $retval; }
/** * Decode a INI string to an array * * @param mixed $resource * @param array $options * @return array */ public function toArray($resource, array $options = []) { $options = array_merge(['process_sections' => true, 'scanner_mode' => INI_SCANNER_RAW], $options); return ArrayUtils::typecast(parse_ini_string(self::getRealResource($resource, $options), $options['process_sections'], $options['scanner_mode'])); }