Signature | Laravel 5 Collections: Converting a Collection's Contents to JSON With toJson
1 public function toJson ( 2 $ options = 0 3 ) ;
Showing 10 of 1,280 results.
1 public function toJson ( 2 $ options = 0 3 ) ;
The following code examples demonstrate the basic use of the toJson method: 1 // Create a new collection instance. 2 $ collection = new Collection ( [ 3 [ ' name ' => ' Shirley ' , ' age ' => 60 ] , 4 [ ' name ' => ' John ' , ' age ' => 55 ] 5 ] )...
The toJson method internally makes a call to PHP's json_encode function. Unlike PHP's json_encode function, the toJson method does not provide a way to specify the depth (essentially how many arrays are nested inside of each other) to which data...
The signature of the random method is: 1 public static function random ( 2 $ length = 16 3 ) ;
It should also be noted that the random method remove the following characters: Character / + =
A RuntimeException will be thrown if a call is made to random without the OpenSSL extension installed. The following examples show sample output. Because the intention of the random method is to generate a random string, any output you get will...
The str_random function is a shortcut to calling Str::random . This function is declared in the global namespace.
The signature of the config function is: 1 function config ( ) ; 2 3 function config ( [ 4 $ key , 5 $ value = null 6 ] ) ; 7 8 function config ( 9 $ key = null , 10 $ default = null 11 ) ;
The following example shows how to resolve an instance of Illuminate\Config\Repository from the Service Container: 1 // Calling the `config` function without any arguments 2 $ configRepository = config ( ) ; After the above code has executed, the...
The config function can be used to set configuration values if the provided $key is an array, and no $default value is supplied (or the $default value supplied is null ). If multiple items are passed in the array, all key/value pairs will added to...