473,503 Members | 12,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Human readable config files

I am working on an embedded platform. Disk storage is at a premium, so
I am trying not to add any more stuff....

I am reading and writing some data that the user enters through a
webform. The form is an operations schedule for a piece of equipment.

Basically, the schedule consists of repeated actions by the machine, and
it is very simple:

%f %f %d %d %d %d %d

repeated about 10 or 15 times.

I will be storing the data in associative arrays, so I would like a
simple way to write the data in a format easily read by a human.

So, instead of the simple line of numbers, I would like something like this:

< Schedule
< Line
< From %f >
< To %f >
< Op1 true >
< Op2 true >
< Op3 false >
< Op4 true >
</ Line>
.... [more lines as needed]
</ Schedule>

I was thinking of XML, but it looks as though XML uses external libs and
is fairly complex to use in PHP....

Since the data is stored in an associative array basically using the
above structure, is there a way to dump an array to file and then read
it back?

Something like print_r, but using file ops and also a read_r to read it
into the array?

Bascially, I am looking for the simplest way to create something that
looks sort of like XML....
Apr 14 '06 #1
5 1720
Hi,

You might try to serialize an array and deserialize it later.
http://www.php.net/serialize
Captain Dondo wrote:
I am working on an embedded platform. Disk storage is at a premium, so
I am trying not to add any more stuff....

I am reading and writing some data that the user enters through a
webform. The form is an operations schedule for a piece of equipment.

Basically, the schedule consists of repeated actions by the machine, and
it is very simple:

%f %f %d %d %d %d %d

repeated about 10 or 15 times.

I will be storing the data in associative arrays, so I would like a
simple way to write the data in a format easily read by a human.

So, instead of the simple line of numbers, I would like something like
this:

< Schedule
< Line
< From %f >
< To %f >
< Op1 true >
< Op2 true >
< Op3 false >
< Op4 true >
</ Line>
... [more lines as needed]
</ Schedule>

I was thinking of XML, but it looks as though XML uses external libs and
is fairly complex to use in PHP....

Since the data is stored in an associative array basically using the
above structure, is there a way to dump an array to file and then read
it back?

Something like print_r, but using file ops and also a read_r to read it
into the array?

Bascially, I am looking for the simplest way to create something that
looks sort of like XML....

Apr 14 '06 #2

Captain Dondo wrote:
I am working on an embedded platform. Disk storage is at a premium, so
I am trying not to add any more stuff....

I am reading and writing some data that the user enters through a
webform. The form is an operations schedule for a piece of equipment.

Basically, the schedule consists of repeated actions by the machine, and
it is very simple:

%f %f %d %d %d %d %d

repeated about 10 or 15 times.

I will be storing the data in associative arrays, so I would like a
simple way to write the data in a format easily read by a human.

So, instead of the simple line of numbers, I would like something like this:

< Schedule
< Line
< From %f >
< To %f >
< Op1 true >
< Op2 true >
< Op3 false >
< Op4 true >
</ Line>
... [more lines as needed]
</ Schedule>

I was thinking of XML, but it looks as though XML uses external libs and
is fairly complex to use in PHP....

Since the data is stored in an associative array basically using the
above structure, is there a way to dump an array to file and then read
it back?

Something like print_r, but using file ops and also a read_r to read it
into the array?

Bascially, I am looking for the simplest way to create something that
looks sort of like XML....


How about the WDDX functions? http://fi.php.net/wddx

Apr 14 '06 #3
Chung Leong wrote:
Bascially, I am looking for the simplest way to create something that
looks sort of like XML....

How about the WDDX functions? http://fi.php.net/wddx


Wow! That looks really interesting....

Do you happen to know if there is a C parser for wddx? Google finds
nothing...

My backend is written in C....
Apr 14 '06 #4
Thanks, and never mind; I found XML_for_morons like me:

http://keithdevens.com/software/phpxml

Perfect.

:-)
Apr 14 '06 #5
Hi,

I hope I didn't get you wrong, but assuming you don't need any DOM
operations, you can just build a string containing your XML and write it
to a file with file_put_contents($filename).

To read it, you could use (PHP 5-only) the build-in SimpleXML-API, which
is very fast and easy to handle for reading purposes:
http://www.php.net/manual/en/ref.simplexml.php

For PHP 4, you could include the also easy to handle XML-Parser from the
PEAR repository:
http://www.php.net/manual/en/ref.simplexml.php
Captain Dondo wrote:
I am working on an embedded platform. Disk storage is at a premium, so
I am trying not to add any more stuff....

I am reading and writing some data that the user enters through a
webform. The form is an operations schedule for a piece of equipment.

Basically, the schedule consists of repeated actions by the machine, and
it is very simple:

%f %f %d %d %d %d %d

repeated about 10 or 15 times.

I will be storing the data in associative arrays, so I would like a
simple way to write the data in a format easily read by a human.

So, instead of the simple line of numbers, I would like something like
this:

< Schedule
< Line
< From %f >
< To %f >
< Op1 true >
< Op2 true >
< Op3 false >
< Op4 true >
</ Line>
... [more lines as needed]
</ Schedule>

I was thinking of XML, but it looks as though XML uses external libs and
is fairly complex to use in PHP....

Since the data is stored in an associative array basically using the
above structure, is there a way to dump an array to file and then read
it back?

Something like print_r, but using file ops and also a read_r to read it
into the array?

Bascially, I am looking for the simplest way to create something that
looks sort of like XML....

Apr 15 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1722
by: Dave Smithz | last post by:
Hi there, As a newbie to PHP is it in anyway possible for a casual web surfer to actually get to see the PHP behind my .php file. E.g. if index.php contained PHP code to check if the page...
13
2981
by: Maxim Khesin | last post by:
I want to have a config file with my python proggie, satisfying the following requirements: 1) support key->(value, default) 2) simple and intuitive to read and edit 3) easyly readable into a...
4
2157
by: aj | last post by:
DB2 WSE 8.1 FP5 Red Hat Linux AS 2.1 I am working on a Java-Swing based interface for a DB2 database, and want to display more human-readable error meesages to the end user when/if a database...
4
2947
by: John Baro | last post by:
I need to determine which fonts are human readable. Webdings, wingdings etc.. are not. Is there any easy way to accomplish this? Cheers JB
5
2774
by: mphanke | last post by:
Hi, can somebody tell me how to convert the date from a Paradox .DB to human readable format? I need to write a tool to convert the 4 Bytes representing the date to a human readable format. ...
4
2089
by: KenFehling | last post by:
Hello. I am wondering if there exists a piece of software that takes multiple .js files that are nicely indented and commented and create one big tightly packed .js file. I'm hoping the one file...
3
3585
by: Sanyog Garg | last post by:
hi I want to open a binary file that contains information in Ulong, Int and char form. now i want to convert this file into human readable form so that i can read the information contained in this...
0
1468
by: Rob Weir | last post by:
On 13 Aug 2008, rkmr wrote: http://mail.python.org/pipermail/python-list/1999-December/018519.html is a good start - just need to change the table to something like:: _abbrevs = (and add a...
5
13529
by: August Karlstrom | last post by:
Hi, I'm looking for a function that *returns* a human readable string representation of an array rather than prints it so I can use it with the error_log procedure. Any clues? August
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.