Solved

push generates error

Posted on 2013-05-17
2
231 Views
Last Modified: 2013-05-17
<?php
$arrFirst = array("liquor_type","varietal","bottle_region","distributor");
$arrLast = array("smith","jones","parker");

$arrFirst_text = array("wine_quantity","wine_price");
$arrLast_text = array("smith","jones","parker");

//$arr_mysql=array_push($arrFirst,$arrFirst_text);
$arr_mysql=array("liquor_type","varietal","bottle_region","distributor","wine_quantity","wine_price");

foreach ($arr_mysql as &$tablename) {
  echo '<br>'.$tablename;
}  

Open in new window


works

but when I use push
$arr_mysql=array_push($arrFirst,$arrFirst_text);

no output and warning
Warning: Invalid argument supplied for foreach() in C:\Users\Acer\Documents\NuSphere PhpED\Projects\noname162.php on line 11
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 39176195
The array_push() function returns the new number of elements in an array. Try just array_merge()  instead:

$arr_mysql = array_merge($arrFirst, $arrFirst_text);
0
 

Author Closing Comment

by:rgb192
ID: 39176209
array merge works

thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question