### PHP Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-kebab-align-not-string.txt A basic example of a PHP array with mixed keys (string and integer) and nested structures. This showcases common array definition patterns. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe-rty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asd-fgh' => [ 'foo-bar-baz' => 'qwe', 2 => 'rty', 'qaw-sed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### PHP Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-kebab-not-string.txt Demonstrates a sample PHP array structure with various key-value pairs, including nested arrays and string keys with hyphens. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe-rty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asd-fgh' => [ 'foo-bar-baz' => 'qwe', 2 => 'rty', 'qaw-sed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### Array Structure Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-pascal-align-as-string.txt Demonstrates a nested array structure with various key-value pairs, including strings, integers, and nested arrays. ```PHP $array = [ 'Foo' => 1, 'Bar' => 2, 'Baz' => 3, 'QweRty' => 'qaz', 'Baq' => [ '0' => 'qwe', '1' => 'rty', 'Asd' => 'zxc', ], 'AsdFgh' => [ 'FooBarBaz' => 'qwe', '2' => 'rty', 'QawSed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### Install Pretty Array via Composer Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md This snippet shows how to install the Pretty Array package using Composer, the dependency manager for PHP. It ensures you have the latest stable version. ```bash composer require dragon-code/pretty-array ``` -------------------------------- ### PHP Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-pascal-not-string.txt Demonstrates a sample PHP array structure with various data types and nested arrays. ```php $array = [ 'Foo' => 1, 'Bar' => 2, 'Baz' => 3, 'QweRty' => 'qaz', 'Baq' => [ 0 => 'qwe', 1 => 'rty', 'Asd' => 'zxc', ], 'AsdFgh' => [ 'FooBarBaz' => 'qwe', 2 => 'rty', 'QawSed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### Example JSON Data Structure Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/json.txt This snippet demonstrates a typical JSON object with various data types including numbers, strings, nested objects, and keys with spaces. It serves as an example input for pretty-printing utilities. ```json { "foo": 1, "bar": 2, "baz": 3, "qwe rty": "qaz", "baq": { "0": "qwe", "1": "rty", "asd": "zxc" }, "asd fgh": { "foo bar baz": "qwe", "2": "rty", "qaw sed": "zxc" }, "2": "iop" } ``` -------------------------------- ### PHP Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-camel-align-not-string.txt Demonstrates a sample PHP array structure with various data types and nested arrays. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qweRty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asdFgh' => [ 'fooBarBaz' => 'qwe', 2 => 'rty', 'qawSed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### PHP Array Structure Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-snake-not-string.txt This snippet illustrates a complex PHP array with mixed keys (string and integer), nested arrays, and string keys containing underscores. It serves as a foundational example for array manipulation. ```PHP $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe_rty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asd_fgh' => [ 'foo_bar_baz' => 'qwe', 2 => 'rty', 'qaw_sed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### Example Array Output (String Keys) Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md This is the resulting formatted array output after calling `setKeyAsString()`. All numeric keys from the original array are converted to strings in the output. ```text [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwerty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asdfgh' => [ 'foobarbaz' => 'qwe', '2' => 'rty', 'qawsed' => 'zxc', ], '2' => 'iop', ] ``` -------------------------------- ### PHP Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-snake-as-string.txt A sample PHP array demonstrating different data types and nesting levels. It includes string keys, integer keys, and nested arrays. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe_rty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asd_fgh' => [ 'foo_bar_baz' => 'qwe', '2' => 'rty', 'qaw_sed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### PHP Associative Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/align-as-string.txt Demonstrates a multi-level associative array in PHP with diverse key-value pairs, including strings with spaces and nested arrays. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe rty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asd fgh' => [ 'foo bar baz' => 'qwe', '2' => 'rty', 'qaw sed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### PHP Associative and Nested Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-snake-align-not-string.txt This snippet demonstrates a complex PHP array structure including associative keys, nested arrays, and mixed key types. It serves as a foundational example for array manipulation within the project. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe_rty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asd_fgh' => [ 'foo_bar_baz' => 'qwe', 2 => 'rty', 'qaw_sed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### PHP Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-camel-as-string.txt A sample PHP array demonstrating various data types, including strings, integers, and nested arrays. This serves as a basic input for array formatting utilities. ```PHP $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qweRty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asdFgh' => [ 'fooBarBaz' => 'qwe', '2' => 'rty', 'qawSed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### Array Structure Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-pascal-align-not-string.txt Demonstrates a complex array structure with mixed keys (string and integer) and nested arrays. This format is common in configuration files or data representation. ```PHP $array = [ 'Foo' => 1, 'Bar' => 2, 'Baz' => 3, 'QweRty' => 'qaz', 'Baq' => [ 0 => 'qwe', 1 => 'rty', 'Asd' => 'zxc', ], 'AsdFgh' => [ 'FooBarBaz' => 'qwe', 2 => 'rty', 'QawSed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### Example Array Output (Numeric Keys) Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md This is the resulting formatted array output when using the `raw()` method without any key conversion. Numeric keys are preserved as they were in the original array. ```text [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwerty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asdfgh' => [ 'foobarbaz' => 'qwe', 2 => 'rty', 'qawsed' => 'zxc', ], 2 => 'iop', ] ``` -------------------------------- ### PHP Associative Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-camel-align-as-string.txt This snippet demonstrates the creation and structure of a complex associative array in PHP, including nested arrays and mixed data types. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qweRty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asdFgh' => [ 'fooBarBaz' => 'qwe', '2' => 'rty', 'qawSed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### PHP Associative Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-kebab-align-as-string.txt This snippet showcases a complex PHP associative array with nested structures and mixed key types, including strings, integers, and hyphenated strings. It demonstrates data organization and potential use cases for configuration or structured data representation. ```php $data = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe-rty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asd-fgh' => [ 'foo-bar-baz' => 'qwe', '2' => 'rty', 'qaw-sed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### PHP Associative and Indexed Array Example Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-pascal-as-string.txt This snippet showcases a PHP array containing a mix of string keys (associative) and integer keys (indexed), including nested arrays with mixed key types. It demonstrates basic data structure definition in PHP. ```php $array = [ 'Foo' => 1, 'Bar' => 2, 'Baz' => 3, 'QweRty' => 'qaz', 'Baq' => [ '0' => 'qwe', '1' => 'rty', 'Asd' => 'zxc', ], 'AsdFgh' => [ 'FooBarBaz' => 'qwe', '2' => 'rty', 'QawSed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### PHP Array Structure Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/align-not-string.txt This snippet showcases a complex PHP array with string and integer keys, nested arrays, and mixed value types. It serves as an example of data structuring in PHP. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe rty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asd fgh' => [ 'foo bar baz' => 'qwe', 2 => 'rty', 'qaw sed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### PHP Array Structure Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/not-string.txt This snippet showcases a complex PHP array with string keys, integer keys, and nested arrays. It includes examples of associative and indexed elements, as well as arrays containing other arrays. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe rty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asd fgh' => [ 'foo bar baz' => 'qwe', 2 => 'rty', 'qaw sed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### PHP Configuration Array Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/custom-array.txt A sample PHP configuration array demonstrating nested structures and key-value pairs. This format is commonly used for application settings. ```php return [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe rty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asd fgh' => [ 'foo bar baz' => 'qwe', '2' => 'rty', 'qaw sed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### PHP Configuration Array Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/storing.php.txt This snippet represents the main configuration structure for the project, defined as a PHP associative array. It includes simple key-value pairs, nested arrays, and mixed key types. ```php 1, 'bar' => 2, 'baz' => 3, 'qwerty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asdfgh' => [ 'foobarbaz' => 'qwe', 2 => 'rty', 'qawsed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### Pretty Print PHP Array Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-snake-align-as-string.txt Demonstrates how to pretty-print a complex nested PHP array with custom formatting. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe_rty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asd_fgh' => [ 'foo_bar_baz' => 'qwe', '2' => 'rty', 'qaw_sed' => 'zxc', ], '2' => 'iop', ]; // Assuming a function like prettyPrintArray exists in the library // prettyPrintArray($array); ``` -------------------------------- ### Storing file Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md Stores a formatted array into a PHP file. The `File::make()` method is used to create a file instance from the formatted array, and `store()` saves it. ```php use DragonCode\PrettyArray\Services\File; use DragonCode\PrettyArray\Services\Formatter; $service = Formatter::make(); $formatted = $service->raw($array); File::make($formatted) ->store('foo.php'); ``` -------------------------------- ### Saving string keys with alignment Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md Formats an array ensuring all keys are treated as strings and aligns the equals sign. This is useful for maintaining consistent key formatting. ```php use DragonCode\PrettyArray\Services\Formatter; $service = Formatter::make(); $service->setKeyAsString(); $service->setEqualsAlign(); return $service->raw($array); ``` -------------------------------- ### Storing as JSON Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md Stores a formatted array as a JSON file. The `asJson()` method is called on the formatter before raw formatting, and the result is stored in a .json file. ```php use DragonCode\PrettyArray\Services\File; use DragonCode\PrettyArray\Services\Formatter; $service = Formatter::make(); $service->asJson(); $formatted = $service->raw($array); File::make($formatted) ->store('foo.json'); ``` -------------------------------- ### Saving numeric keys with alignment Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md Formats an array with numeric keys, aligning the equals sign for better readability. This uses the Formatter service and sets the alignment option. ```php use DragonCode\PrettyArray\Services\Formatter; $service = Formatter::make(); $service->setEqualsAlign(); return $service->raw($array); ``` -------------------------------- ### Change key case Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md Formats an array by changing the case of its keys according to specified constants (e.g., PascalCase, camelCase). It utilizes the `setCase` method with constants from `Caseable`. ```php use DragonCode\Contracts\Pretty\Arr\Caseable; use DragonCode\PrettyArray\Services\Formatter; $service = Formatter::make(); $service->setCase(Caseable::PASCAL_CASE); return $service->raw($array); ``` -------------------------------- ### Add Pretty Array to Composer JSON Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md This JSON snippet demonstrates how to manually add the Pretty Array package as a dependency in your project's `composer.json` file. After updating the file, run `composer update`. ```json { "require": { "dragon-code/pretty-array": "^4.0" } } ``` -------------------------------- ### PHP Array Definition Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/as-string.txt This snippet defines a PHP array with a mix of string and integer keys, along with nested arrays. It demonstrates how to structure data in PHP. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe rty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asd fgh' => [ 'foo bar baz' => 'qwe', '2' => 'rty', 'qaw sed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### Save string keys without alignment Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md This PHP code shows how to configure the Pretty Array formatter to treat all keys as strings, even if they are numeric. The `setKeyAsString()` method ensures that numeric keys are output as strings, which can be beneficial for certain IDEs or data processing scenarios. ```php use DragonCode\PrettyArray\Services\Formatter; $service = Formatter::make(); $service->setKeyAsString(); return $service->raw($array); ``` -------------------------------- ### PHP Array Structure Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-camel-not-string.txt This snippet defines a PHP array with a mix of string and integer keys, including nested arrays with different key types. It demonstrates basic array assignment and structure. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qweRty' => 'qaz', 'baq' => [ 0 => 'qwe', 1 => 'rty', 'asd' => 'zxc', ], 'asdFgh' => [ 'fooBarBaz' => 'qwe', 2 => 'rty', 'qawSed' => 'zxc', ], 2 => 'iop', ]; ``` -------------------------------- ### Pretty Print Array Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/simple.txt Formats a given array into a human-readable string. It handles nested arrays and strings containing spaces, ensuring each element is displayed clearly. ```javascript function prettyArray(arr) { return arr.map(item => { if (Array.isArray(item)) { return `[${prettyArray(item)}]`; } else { return `'${item}'`; } }).join(', '); } const myArray = [ 'foo', 'bar', 'baz', 'qwe rty', [ 'qwe', 'rty', 'zxc', ], [ 'foo bar baz', 'rty', 'qaw sed', ], 'iop', ]; console.log(`[${prettyArray(myArray)}]`); ``` -------------------------------- ### Save numeric keys without alignment Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md This PHP code demonstrates how to use the `Formatter` service from the Pretty Array package to export an array while preserving its original numeric keys without any alignment. This is useful when the exact numeric keys are important. ```php use DragonCode\PrettyArray\Services\Formatter; $service = Formatter::make(); return $service->raw($array); ``` -------------------------------- ### PHP Array Structure Source: https://github.com/thedragoncode/pretty-array/blob/main/tests/stubs/case-kebab-as-string.txt This snippet showcases a complex PHP array with a mix of string keys (including hyphenated ones) and numeric keys in nested arrays. It demonstrates how to represent hierarchical data in PHP. ```php $array = [ 'foo' => 1, 'bar' => 2, 'baz' => 3, 'qwe-rty' => 'qaz', 'baq' => [ '0' => 'qwe', '1' => 'rty', 'asd' => 'zxc', ], 'asd-fgh' => [ 'foo-bar-baz' => 'qwe', '2' => 'rty', 'qaw-sed' => 'zxc', ], '2' => 'iop', ]; ``` -------------------------------- ### Saving simple array Source: https://github.com/thedragoncode/pretty-array/blob/main/README.md Formats an array into a simple, non-associative structure. This is useful for arrays where key-value pairs are not the primary focus. ```php use DragonCode\PrettyArray\Services\Formatter; $service = Formatter::make(); $service->setSimple(); return $service->raw($array); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.