test2.php 599 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. //
  3. // $Id$
  4. //
  5. require ( "sphinxapi.php" );
  6. $docs = array
  7. (
  8. "this is my test text to be highlighted",
  9. "this is another test text to be highlighted",
  10. );
  11. $words = "test text";
  12. $index = "test1";
  13. $opts = array
  14. (
  15. "before_match" => "<b>",
  16. "after_match" => "</b>",
  17. "chunk_separator" => " ... ",
  18. "limit" => 400,
  19. "around" => 15
  20. );
  21. $cl = new SphinxClient ();
  22. $res = $cl->BuildExcerpts ( $docs, $index, $words, $opts );
  23. if ( !$res )
  24. {
  25. die ( "ERROR: " . $cl->GetLastError() . ".\n" );
  26. } else
  27. {
  28. foreach ( $res as $entry )
  29. {
  30. $n++;
  31. print "n=$n, res=$entry\n";
  32. }
  33. }
  34. //
  35. // $Id$
  36. //
  37. ?>