how to store a hash table in the disk ? it is a general ques ans pls..

Hey.

By "hash table" I assume you mean an associative array?
There isn't anything in PHP like the HashTable you find in .Net or Java. (There is no need for it, because of PHPs flexible array type.)

Anyhow, you can use the serialize and unserialize functions to create a data packet that you can store on your HDD, and restore it.

For example, to save an array to a file:

<?php
// Random example data
$fields = array(
  array('name' => 'Firstname', 'required' => true),
  array('name' => 'Lastname', 'required' => true),
  array('name' => 'Email', 'required' => true),
  array('name' => 'EmailCheck', 'required' => true),
  array('name' => 'Password', 'required' => true),
  array('name' => 'PasswordCheck', 'required' => true)
);

// Serialize it into a storable data packet.
$data = serialize($fields);

// Write the data to a file
$filename = "/path/to/my/file.txt";
file_put_contents($filename, $data);
?>

And to restore it:

<?php
// Fetch the data from a file
$filename = "/path/to/my/file.txt";
$data = file_get_contents($filename);

// Restore the data into it's original form
$fields = unserialize($data);

// Print them, or whatever.
var_dump($fields);
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.