Fatal error: Cannot redeclare array_combine()

Daizzy-Mae
Daizzy-Mae used Ask the Experts™
on
Hi

I'm moving our website to a new server (with the same hosts - easily.co.uk).
I am getting the following error on this page all of a sudden (without changing the code).

Fatal error: Cannot redeclare array_combine() in /xxxx/xxxx/website/admin2/shop_editproduct03.php on line 217

Does anybody know what I can do to not redeclaire the variable? My php is rusty.

Many Thanks

Daisy-Mae
shop-editproduct03.php
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
you are probably migrating from PHP4 to PHP5, and you have declared user function array_combine(), which was not available in PHP4, but exists in PHP5.
From your cource code, delete (or comment) the declaration of the array_combine() function, and then it should work.
Commented:
PHP array_combine is a function:

http://uk.php.net/array_combine

Looks like you're upgrading from PHP4 to PHP5

Either remove the following and use the build in function or rename the function below and change any reference to it to the new name.

function array_combine($keys, $values) {
                      $result = array() ;
                           while( ($k=each($keys)) && ($v=each($values)) ) $result[$k[1]] = $v[1] ;
                      return $result ;
                        }

Author

Commented:
Thank you, how would I rename the function (it seems to be a standard php function)?
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

maybe changing the line #217 from
function array_combine($keys, $values) {
to
function my_array_combine($keys, $values) {

can help??
Commented:
If you just do the following:
function array_combine2($keys, $values) {
    			$result = array() ;
   				while( ($k=each($keys)) && ($v=each($values)) ) $result[$k[1]] = $v[1] ;
    			return $result ;
				}
		 $options=array_combine2($option_label,$option_cost);

Open in new window

Author

Commented:
Thank you VERY much! It works perfectly now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial