Solved

push generates error

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

746 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

9 Experts available now in Live!

Get 1:1 Help Now