Page 1 of 1

array_push problem

Posted: Wed Sep 05, 2007 4:10 am
by grace01
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello,

I migrated a php website from another hosting company. When the website is running on our server, I encounter a problem. I want to display year and month on the php webpage. 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 12 December rather than January to December. My source code is as follow:

Code: Select all

$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");
$array_year = array("2005","2006","2007","2008","2009");
$m_options = array();
while (list($indx,$mth) = each ($array_month)) {
	$tmp_mth->m_title = $mth;
	$tmp_mth->m_value = "?month=".$indx."&year=".$year;
	if ($indx == $month) {
		$tmp_mth->selected = "selected";
	}
	array_push($m_options,$tmp_mth);
	$tmp_mth->selected = "";
}
$y_options = array();
foreach ($array_year as $yr) {
	$tmp_yr->y_title = $yr;
	$tmp_yr->y_value = "?month=".$month."&year=".$yr;
	if ($yr == $year) {
		$tmp_yr->selected = "selected";
	}
	array_push($y_options,$tmp_yr);
	$tmp_yr->selected = "";
print_r ($tmp_yr->y_title);
print_r ($y_options);
}
Would appreciate if anybody can help.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Sep 05, 2007 4:28 am
by playgames
oddball. may be you server has something incrot . and PHP SET LOSTED

try to remake you php :lol:

Posted: Wed Sep 05, 2007 7:53 am
by superdezign
Use the correct

Code: Select all

tags to make the error easier to find.

Re: array_push problem

Posted: Thu Sep 13, 2007 8:58 am
by volka
please try

Code: Select all

erro_reporting(E_ALL);
ini_set('display_errors', true);
$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");

...