You are here

function _search_api_deep_copy in Search API 7

Returns a deep copy of the input array.

The behavior of PHP regarding arrays with references pointing to it is rather weird. Therefore, we use this helper function in theme_search_api_index() to create safe copies of such arrays.

Parameters

array $array: The array to copy.

Return value

array A deep copy of the array.

4 calls to _search_api_deep_copy()
search_api_admin_overview in ./search_api.admin.inc
Page callback that shows an overview of defined servers and indexes.
theme_search_api_admin_fields_table in ./search_api.admin.inc
Returns HTML for a field list form.
theme_search_api_index in ./search_api.admin.inc
Returns HTML for a search index.
theme_search_api_server in ./search_api.admin.inc
Returns HTML for displaying a server.

File

./search_api.module, line 3296
Provides a flexible framework for implementing search services.

Code

function _search_api_deep_copy(array $array) {
  $copy = array();
  foreach ($array as $k => $v) {
    if (is_array($v)) {
      $copy[$k] = _search_api_deep_copy($v);
    }
    elseif (is_object($v)) {
      $copy[$k] = clone $v;
    }
    elseif ($v) {
      $copy[$k] = $v;
    }
  }
  return $copy;
}