PHP Classes

PHP Hashtable Array: Store key-value pairs in hashed arrays

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 8 All time: 11,292 This week: 560Up
Version License PHP version Categories
hashtable 1.0Free For Educatio...5PHP 5, Data types
Description 

Author

This class can store key-value pairs in hashed arrays.

It can compute an integer for the index of a hash table entry based on the key string.

The class uses the computed hash index to find the internal array position to find, insert, delete or update the value of the key, as well clear the whole hash table, check if an entry with a key exists, check if the list is empty or get the size of the list.

Picture of Dev Sharma
  Performance   Level  
Name: Dev Sharma <contact>
Classes: 4 packages by
Country: India India
Age: 21
All time rank: 3213209 in India India
Week rank: 270 Up22 in India India Up
Innovation award
Innovation award
Nominee: 2x

Example

<?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
//
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example An example
Plain text file hash.class.php Class main class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:8
This week:0
All time:11,292
This week:560Up