Download the PHP package popphp/pop-data without Composer
On this page you can find all versions of the php package popphp/pop-data. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download popphp/pop-data
More information about popphp/pop-data
Files in popphp/pop-data
Package pop-data
Short Description Pop Data Component for Pop PHP Framework
License New BSD
Homepage http://www.popphp.org/
Informations about the package pop-data
pop-data
END OF LIFE
The pop-data
component v2.1.0 is now end-of-life. The CSV sub-component has
been forked and pushed into its own repository:
- popphp/pop-csv
OVERVIEW
pop-data
provides a streamlined way to convert common data types. With it, you can easily give it
some native PHP data and quickly produce a serialized version of that data in a common data type,
such as CSV, JSON, SQL, XML or YAML. Or, conversely, you can give it some serialized data, an it
will auto-detect the format and convert it to native PHP data.
pop-data
is a component of the Pop PHP Framework.
INSTALL
Install pop-data
using Composer.
composer require popphp/pop-data
BASIC USAGE
Serialize Data
The $csvString variable now contains:
first_name,last_name
Bob,Smith
Jane,Smith
The $jsonString variable now contains:
[
{
"first_name": "Bob",
"last_name": "Smith"
},
{
"first_name": "Jane",
"last_name": "Smith"
}
]
The $sqlString variable now contains:
INSERT INTO data (first_name, last_name) VALUES
('Bob', 'Smith'),
('Jane', 'Smith');
The $xmlString variable now contains:
<?xml version="1.0" encoding="utf-8"?>
<data>
<row>
<first_name>Bob</first_name>
<last_name>Smith</last_name>
</row>
<row>
<first_name>Jane</first_name>
<last_name>Smith</last_name>
</row>
</data>
The $yamlString variable now contains:
---
- first_name: Bob
last_name: Smith
- first_name: Jane
last_name: Smith
...
Unserialize Data
You can either pass the data object a direct string of serialized data or a file containing a string of serialized data. It will detect which one it is and parse it accordingly.