You are here

function _footnotes_helper_find_footnote in Footnotes 7.3

Same name and namespace in other branches
  1. 6.2 footnotes.module \_footnotes_helper_find_footnote()
  2. 7.2 footnotes.module \_footnotes_helper_find_footnote()

Search the $store_matches array for footnote text that matches and return the value.

Note: This does a linear search on the $store_matches array. For a large list of footnotes it would be more efficient to maintain a separate array with the footnote content as key, in order to do a hash lookup at this stage. Since you typically only have a handful of footnotes, this simple search is assumed to be more efficient. (but was not tested).

@author djdevin (see http://drupal.org/node/808214)

Parameters

string The footnote text:

array The matches array:

Return value

mixed The value of the existing footnote, FALSE otherwise

1 call to _footnotes_helper_find_footnote()
_footnotes_replace_callback in ./footnotes.module
Helper function called from preg_replace_callback() above

File

./footnotes.module, line 140
The Footnotes module is a filter that can be used to insert automatically numbered footnotes into Drupal texts.

Code

function _footnotes_helper_find_footnote($text, &$store_matches) {
  if (!empty($store_matches)) {
    foreach ($store_matches as &$fn) {
      if ($fn['text'] == $text) {
        return $fn['value'];
      }
    }
  }
  return FALSE;
}