To::JSON()
Encodes data to JSON string.
Table of Contents
Description
To::JSON(mixed $value, bool|int|string $dent = false): ?string;This method encodes PHP data to JSON string so that it can be stored to a file.
Example
$value = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5];
save('.\lot\asset\data.json', To::JSON($value, true));$value = To::JSON(['a' => 1, 'b' => [1, [2]], 'c' => []], true); // Dent with 4 space(s)
$value = To::JSON(['a' => 1, 'b' => [1, [2]], 'c' => []], 2); // Dent with 2 space(s)
$value = To::JSON(['a' => 1, 'b' => [1, [2]], 'c' => []], "\t"); // Dent with 1 tabTo::HTML()
Decodes HTML special characters.
To::JSON()
Encodes data to JSON string.
To::URL()
Converts private file path to public URL, or decodes URL special characters.
To::_()
Creates a virtual method.
To::__callStatic()
Calls the virtual method that has been created.
To::base64()
Encodes to Base64 string.
To::camel()
Converts current value to camel case.
To::entity()
Converts characters to their corresponding HTML entities.
To::file()
Converts current value to a safe file name.
To::folder()
Converts current value to a safe folder name.
To::kebab()
Converts current value to kebab/slug case.
To::lower()
Converts current value to lower case.
To::pascal()
Converts current value to pascal case.
To::path()
Converts public URL to private file path.
To::query()
Converts PHP array to URL query string.
To::serial()
Serializes data.
To::snake()
Converts current value to snake case.
To::text()
Converts current value to plain text.
To::upper()
Converts current value to upper case.