phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Database: Using Custom Text File as Data Storage Alternative

Tag: database, text file   Category: PHP Database
post: 05 Feb 2008 read: 294


Text Data Storage - Part 1: Data storage alternative which we have learned is use the CSV. CSV can be classified as plain text. But sometimes we require the special format. We can make it own use the custom text file.

For this job, we can use fprint. We have learned at here about fprint().

Example:


<?
$dat = fopen('test.dat', 'w');
$year = 2008;
$month= 2;
$day = 5;
$code = 'BXD';
$property = 'Notebook';
$price = '1990.39';

// first line
fprintf($dat, "%04d-%02d-%02d\n", $year, $month, $day);

// second line
fprintf($dat, "%3s*%-40s %f\n", $code, $property, $price);

fclose($dat);
?>


Series this article:
Database: Using Custom Text File as Data Storage Alternative
Database: Reading Custom Text File Data Storage

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting