Solved

push generates error

Posted on 2013-05-17
2
218 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
2 Comments
 
LVL 34

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
calculated column 12 74
How can I upload multiple images from a HTML form? 2 18
javascript date picker in php while loop 5 28
designing in object programming 12 42
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now