php - Push parts of associative array into another -
I'm thinking how to push some parts of an associative array into another array as a result of the forehead loop.
$ foreach loop after the product array: Any help would be greatly appreciated. Like this?
array (5) {[ "Prodid"] = & gt; String (6) "123456" ["title"] = & gt; String (29) "Test item 1" ["Unit"] = & gt; String (4) "100pk" ["price"] = & gt; String (4) "10.99" ["Bispris"] = & gt; String (4) "11.99"} I only want ['prodid'], ['title'] and ['unit'] array and added in $ liveArray. Results in something like this:
array (1) {[0] = & gt; Array (5) {["prodid"] = & gt; String (6) "123456" ["title"] = & gt; String (29) "Test item 1" ["Unit"] = & gt; String (4) "100pk" ["price"] = & gt; String (4) "10.99" ["Bispris"] = & gt; String (4) "11.99"} [1] = & gt; Array (5) {["prodid"] = & gt; String (6) "123457" ["title"] = & gt; String (29) "Test item 2" ["Unit"] = & gt; String (4) "50pk" ["price"] = & gt; String (4) "11.00" ["Bispris"] = & gt; String (4) "13.00"}}
$ liveArray = array (); $ {Foreach ($ $ result as product) {$ liveArray [] = array ('prodid' => $ product ['prodid'], 'title' = & gt; $ product ['title'], 'Unit' = & gt; $ product ['unit'],); InsertData ($ dbh, $ product); }} While (! Blank ($ rules)); // prevents // if the last element on the page / print_r ($ liveArray) is found;
Comments
Post a Comment