How do I create a block? I am trying to create a block using hook_block, in Drupal 7. I have the following code in my module file (module.module its not actually called that but, this is an example).

function module_race_results_block_info($op = 'list'){
  $block = array();

  if ($op == 'list') {
    $block[0]['info'] = t('Race Results Block');
  }

  return $block;
}

function module_race_results_block_view($delta = 'raceresults') {
  $block = array();

  switch ($delta) {
    case 'raceresults':
      $block['content'] = module_race_results();
      break;
  }

  return $block;
}

function module_race_results() {
  $content = "Testing Race Results Block";

  return $content;
}


How can I test this? The block is not showing up in the blocks list (/admin/structure/block).
Quickly, it's $block['content']=module_race_results(); in your hook_block_view(), and $blocks['raceresults']... in your hook_block_info() so it matches your hook_block_view().

More precisely, this is probably more of what you are trying to accomplish:

function module_race_results_block_info() {
  $blocks = array();

  $blocks['raceresults']['info'] = t('Race Results Block');
  // any more blocks here

  return $blocks;

}


function module_race_results_block_view($delta) {
  $blocks = array();

  switch($delta) {
    case 'raceresults':
      $blocks['subject'] = t('Race Results');
      $blocks['content'] = module_race_results();
      break;

    // any more blocks here

    }
  }

  return $blocks;
}

function module_race_results() {
  $content = "Testing Race Results Block";  // eventually this should become a renderable array instead of plain text or html
  return $content;
}