PHP code example of axp-dev / file-parser
1. Go to this page and download the library: Download axp-dev/file-parser library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
axp-dev / file-parser example snippets
'providers' => [
...
AXP\FileParser\FileParserServiceProvider::class
]
'aliases' => [
...
'FileParser' => AXP\FileParser\Facades\FileParser::class
]
$app->register('AXP\FileParser\FileParserServiceProvider');
class_alias('AXP\FileParser\Facades\FileParser', 'FileParser');
FileParser::json($string) : array
$string = '{"id":1,"name":"A green door","price":12.5,"tags":["home","green"]}';
$data = FileParser::json($string);
print_r($data);
FileParser::xml($string) : array
$string = '<?xml version="1.0" encoding="UTF-8"
FileParser::queryString($string) : array
$string = 'id=1&name=A+green+door&price=12.5&tags%5B0%5D=home&tags%5B1%5D=green';
$data = FileParser::queryString($string);
print_r($data);
FileParser::serialize($string) : array
$string = 'a:4:{s:2:"id";s:1:"1";s:4:"name";s:12:"A green door";s:5:"price";s:4:"12.5";s:4:"tags";a:2:{i:0;s:4:"home";i:1;s:5:"green";}}';
$data = FileParser::serialize($string);
print_r($data);
FileParser::ini($string) : array
$string = '[card]
id = 1
name = "A green door"
price = 12.5
tags[] = home
tags[] = green';
$data = FileParser::ini($string);
print_r($data);
FileParser::csv($string, $delimiter = ';') : array
$string = 'Title1;Title2;Title3
one;two;three
example1;example2;example3';
$data = FileParser::csv($string);
print_r($data);
FileParser::yaml($string) : array
$string = 'latitude: 52.7157856867271
longitude: -8.8741735070805
zoom: 15';
$data = FileParser::yaml($file);
print_r($data);