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.

(forex) $ {foreach ($ $ $ result as product) {$ liveArray = $ product ['prodid'] ['title'] ['unit' ]; InsertData ($ dbh, $ product); }} While (! Blank ($ rules)); // The last element is found on the page, the loop prevents

$ foreach loop after the product array:

  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"}}   

Any help would be greatly appreciated.

Like this?

  $ 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

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -