473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem with array_push

Hello,

My php program cannot display result correctly. After run array_push($y_options,$tmp_yr), $y_options doesn't show 2005, 2006, 2007, 2008, 2009. $y_options only show 2009, 2009, 2009, 2009, 2009.

Same for $m_options. It only show December rather than January to December. My source code is as follow:

Code: ( php )
Expand|Select|Wrap|Line Numbers
  1. $array_month = array("1"=>"January","2"=>"Febuary","3"=>"March","4"=>"April","5"=>"May","6"=>"June","7" =>"July","8"=>"August","9"=>"September","10"=>"October","11"=>"November","12"=>"December");
  2. $array_year = array("2005","2006","2007","2008","2009");
  3. $m_options = array();
  4. while (list($indx,$mth) = each ($array_month)) {
  5.     $tmp_mth->m_title = $mth;
  6.     $tmp_mth->m_value = "?month=".$indx."&year=".$year;
  7.     if ($indx == $month) {
  8.         $tmp_mth->selected = "selected";
  9.     }
  10.     array_push($m_options,$tmp_mth);
  11.     $tmp_mth->selected = "";
  12. }
  13. $y_options = array();
  14. foreach ($array_year as $yr) {
  15.     $tmp_yr->y_title = $yr;
  16.     $tmp_yr->y_value = "?month=".$month."&year=".$yr;
  17.     if ($yr == $year) {
  18.         $tmp_yr->selected = "selected";
  19.     }
  20.     array_push($y_options,$tmp_yr);
  21.     $tmp_yr->selected = "";
  22. print_r ($tmp_yr->y_title);
  23. print_r ($y_options);
  24. }
  25.  

Would appreciate if anybody can help.
Sep 6 '07 #1
0 807

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phil Powell | last post by:
If $val is the following: ....Just revamped the site's Content Management Application I built.. so do bear in mind.. sorry! Phil stripslashes(htmlspecialchars($val)) should produce the...
4
by: Phil Powell | last post by:
Hi, I am basing this upon my study of the array_search and array_keys functions in www.php.net and www.zend.com and www.nyphp.org. I have this array, $this->propertyArray, which I have passed...
0
by: Phil Powell | last post by:
I traced the problem to what I believe is when I use the included content library script into the viewinterns.php page. This script will repeatedly instantiate a DateGroupHTMLGenerator class...
1
by: Muttly | last post by:
Hey all. I'm trying to upload multiple files. I'm using the chm file from php.net to help me figure it out. I also checked online and say theres a problem with the file. Anyway My html looks like...
3
by: Malcolm | last post by:
I want to put the contents of a csv file into a 2 dimensional array so that I can access any element in a $table manner and have come up with the following code: $complete = file("source.csv");...
33
by: Geoff Berrow | last post by:
I may have mentioned that I run an Introduction to PHP course at a local college (very basic - I'm no PHP expert). Well, one of my students was doing really well so I set him some extension work. ...
2
by: Nicholas Sherlock | last post by:
Hey all, I wrote a class to represent a node in a site navigation tree which contains methods for building the tree from the database. I also wrote some routines to print out the whole tree,...
2
by: kardon33 | last post by:
Ok what i need to do is ping somthing with a function i have and push the results with the ip as the key value in the array. heres my code so far i know it doesnt work but that is the main concept. ...
1
by: laastos | last post by:
I created two classes Conexion.php and Consulta.php, I show you the code: /* Clase Conexion: Clase encargada de conectarse directamente con la base de datos de MySQL. */ class Conexion {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.