1. Go to this page and download the library: Download ixnode/php-container 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/ */
ixnode / php-container example snippets
use Ixnode\PhpContainer\File;
$exists = (new File('path-to-file'))->exist();
true || false
$fileSize = (new File('path-to-file'))->getFileSize();
1523943
$fileSizeHuman = (new File('path-to-file'))->getFileSizeHuman();
1.45 MB
$content = (new File('path-to-file'))->getContentAsText();
line 1
line 2
line 3
...
$content = (new File('path-to-json-file'))->getJson()->getJsonStringFormatted();
{
"data": "Content of file 'path-to-json-file'."
}
use Ixnode\PhpContainer\Json;
$json = (new Json(['data' => 'json']))->getJsonStringFormatted();
$array = (new Json('{"data": "json"}'))->getArray();
[
'data' => 'json',
]
$array = (new Json(new File('path-to-json-file')))->getArray();
[
"data" => "Content of file 'path-to-json-file'.",
]