php - Create a string version of an array -
I do not know that with the title it tells very well, so I am trying to get it.
With this script, people can change the value of the configuration variable that flies like this:
Config :: write ('General.load', array '(' plugin1 ',' Plugin2 '), is true);
In that example, it changes the General.load config variable in an array, and sets 3 to the right, which means that it can be saved. / P>
The one I am trying to include is a way to save the part when a user makes a call, then Config :: save ()
is any of these configuration variables Is hidden by means which was written and the 3 parameters that were set to true were set to true.
This works perfect for boolean, strings, inters, floats, etc. But when it comes to the array, by default, by default, this file contains the "array" array ('plugin1', 'plugin2') ". "
So I started to develop a small script that converts the array into a string based array.
This is the task (I was put on strangely on pastebin , It was weird formatted here):
It works up to one degree.
If you supply it with something like this: / P>
$ Array_to_string = ''; $ array = array ('welcome', 'to', 'mine', array ('website')); array_bild ($ array_to_string, $ array, 0); ($ Array_to_string);
This output will be:
array ('welcome', 'to', 'my', array ('website'))
This worked almost though if I input like this:
$ array_to_string = ''; $ Array = array ('welcome', 'to' Array ('array', 'foo' => 'bar')); array_bild ($ array_to_string, $ array, 0); die ($ array_to_string), 'my' ;
The output is:
array ('welcome', 'to', 'mary', array ('website') array ('bye', 'foo' = & Gt; 'bar'),))
I went to code, and I'm pretty sure That's what I can do to fix this.
If anyone has any thoughts on my wrongdoing, then let us know.
Cheers.
Cheers.
Try
- - Output or A parcel string of one variable represents
Example from the PHP manual:
$ a = array (1, 2, array ("a" , "B", "c")); Var_export (one $); // output array (0 = & gt; 1, 1 = 2, 2 => array (0 = & gt; 'A', 1 = & gt; 'B', 2 = & gt; C ',),)
See my answer on how to use it in a config class.
Comments
Post a Comment