CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • undefined function array_intersect_key() in contribution page
Pages: [1]

Author Topic: undefined function array_intersect_key() in contribution page  (Read 1177 times)

chrisdaems

  • Guest
undefined function array_intersect_key() in contribution page
March 15, 2008, 12:30:23 pm
I upgraded CiviCRM 1.9 to 2.0 and created a new contribution page.
The test-drive and live page returned following error:

Call to undefined function array_intersect_key()

The function array_intersect_key() is a PHP 5.1 function and will return an error if it is used in an earlier PHP version, See following bug result:
http://bugs.php.net/bug.php?id=31961


I found an easy fix and worked at least for me. I thought that it might be useful to post it here in case somebody else has the same problem.

I added the following function in ContributionBase.php

Code: [Select]
function array_intersect_key($arr1, $arr2) {
  $res = array();
  foreach($arr1 as $key=>$value) {
    if(array_key_exists($key, $arr2)) $res[$key] = $arr1[$key];
  }
  return $res;
}

The workaround can also be found at:
http://www.php.net/manual/en/function.array-intersect-key.php

chris

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: undefined function array_intersect_key() in contribution page
March 15, 2008, 12:43:20 pm

Note that civicrm v2.0 supports only php 5.2+ (http://wiki.civicrm.org/confluence/display/CRM/CiviCRM+v2.0)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

chrisdaems

  • Guest
Re: undefined function array_intersect_key() in contribution page
March 15, 2008, 01:14:38 pm
Currently I'm running some tests and till now the only error I got was the one in subject.
There are really some nice new features in version 2.0
I'm also very impressed by the installation.

But I better downgrade (rebuild) again to CiviCRM 1.9
My hosting company is on php version 5.0.4.

Thanks for the good work
Chris

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • undefined function array_intersect_key() in contribution page

This forum was archived on 2017-11-26.