Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Flatten a multidimensional array without recursion

$
0
0
This is the meal planner app I'm still working on. I've gotten a lot of useful help so far. You can see the view source at http://maureenmoore.com/momp_tests/122212.html

I am using the following in my process.php (which the jquery form gets submitted to)
$stack = array();

foreach ($_REQUEST as $key => $value) {
			array_push($stack,$value);
          }
$stack = array_values($stack);

print_r($stack);

$comma_separated = implode(",", $stack);

echo "\n\n" . $comma_separated . "\n\n";


When I click the submit button at localhost it shows an error for array to string conversion because it's a multidimensional array. How can I get rid of the first null key without resorting to a recursive function? I don't see the error any more now that I've uploaded it to my hosting account but it's not printing a comma-separated list because it's a multidimensional array with a key of null.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>