Reply to Re: Human readable config files

Your name:

Reply:


Posted by Robin on 04/14/06 23:06

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....

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация