PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Dev Sharma   PHP Hashtable Array   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: An example
Class: PHP Hashtable Array
Store key-value pairs in hashed arrays
Author: By
Last change:
Date: 5 years ago
Size: 1,150 bytes
 

Contents

Class file image Download
<?php
require_once 'hash.class.php';

//example 1
$init = new hashtable;
$init->set('test', 'data');

$result = $init->get('test'); //returns data as your value
//

//example 2
$init = new hashtable;
$init->set('test', 'data');
$init->set('test2', 55);
$init->deleteit('test');

$result = $init->get('test'); //the value does not exist
//

//example 3
$init = new hashtable;
$result = $init->isempty(); //true
$init->set('getme', 'apple');
$result1 = $init->isempty(); //false
//

//example 4
$init = new hashtable;
$init->set('getme', 'apple');
$init->set('getme2', 'apple2');
$init->set('getme3', 'apple3');

$result = $init->isempty();
if(!
$result) $init->clear();

$result = $init->get('getme'); //the value does not exist
//

//example 5
$init = new hashtable;
$init->set('getme', 'apple');
$init->set('getme2', 'apple2');
$init->set('getme3', 'apple3');

$result = $init->getsize();

if(
$result >= 3) //code
//

//example 6
$init = new hashtable;
$init->set('getme', 'apple');
$init->set('getme2', 'apple2');
$init->set('getme3', 'apple3');

$result = $init->has('getme'); //true
//
?>