Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Richard Carson  >  Ssearch  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Ssearch
Search and rank text results in an array
Author: By
Last change:
Date: 2011-01-08 19:27
Size: 736 bytes
 

Contents

Class file image Download
<?php
    
require('Ssearch.class.php'); //Include the class file

    
$Dataset = array(
                    array(
                        
"Testing Search"
                        
),
                    array(
                        
"Searcheable"
                        
),
                    array(
                        
"Searching"
                        
),
                    array(
                        
"Bananas."
                    
)
                ); 
//Example data set (only one text row per object here, but you can have as many as you want
                    
    //Declare and set up search object
    
$MySearch = new Ssearch();
    
$MySearch->SetScore(1001);
    
$MySearch->SetData($Dataset);

    
//Query string
    
$query "Testing the Search Feature";

    
//Perform search
    
$results $MySearch->Search($query);

    
//Display results
    
foreach ($results as $object)
    {
        echo 
$object[0] . " - " $object["score"] . "</br>\n";
    }
?>