All pastes #339172 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-02-03 22:22 UTC
rendered paste body
<?
  $text = "abcdefghtasdf [3] abcd"; 
  $array = array("jedna","dva","tri");

  $pattern = '/\[(\d+)\]/e';
  $replacement = '<a href="index.php?action=$1">$array[\\1]</a>';
  echo preg_replace($pattern, $replacement, $text);
?>