Solved

push generates error

Posted on 2013-05-17
2
222 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

813 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

11 Experts available now in Live!

Get 1:1 Help Now