Parse_str() more than 1 strip

$checkbox = $_POST['checkbox']['title-name']['title-description']
$params = array();             
parse_str($checkbox, $params);

however this code work perfectly with 1 strip how to do with more than 1 strip, like

$checkbox = $_POST['checkbox']['title-name-value']['title-description-value']

thanks for advice

Just use explode. parse_str is deprecated in PHP 7 and will most likely be removed in future versions.

No it’s not:

Using this function without the result parameter is highly DISCOURAGED and DEPRECATED as of PHP 7.2.

https://secure.php.net/manual/en/function.parse-str.php

(emphasis mine)

2 Likes

Oops, sorry 7.2

@adyoi I don’t really understand the question. What do you want to do exactly? What are the values in those variables?

i want to produce array with post multiple array

I’m sorry, but I really don’t understand what you want :thinking:

Could you give an example of expected output?

I think what his basic question is, Scallio, is “How do I loop through my inputs from a POST variable array.” but i’m just guessing (that “value” in his second line being a variable-replacement text sort of thing?)

Though I must say I dont actually understand why something called ‘title-description’ is a parse-able string…

I don’t know what is meant by “one strip”.

My take is that a new array comprised of only certain nested array values is wanted. Or maybe the trouble is in getting the nested array values.

For example, in pseudocode

[A] => 
  [0] => 
    [a] => "foo" 
    [b] => "bar" 
  [1] => 
    [x] => "baz" 
[B] => 
  [0] => 
    [a] => "uno" 
    [b] => "dos" 
...

Either a new array like

[0] => "foo" 
[1] => "uno" 
... 

or a way to loop through the multi-dimensional array and get the values “foo”, “uno”, etc. so they can be parsed as strings.

Part of what I find confusing is that the multi-dimensional array is a form POST array. I have never seen one nested to that extent. Two levels, yes. But not three. I agree there are no reasons a form couldn’t be that complex, but I suspect it might be better to simplify the form to allow for less complex back end processing.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.