开发者

Building a data dictionary in web

Not a dictionary for language, but data. I.e Car1[Make="Honda",Model="Accord",Colour="Red"]

That's how I'd do it in Python, but by the look of things, it's harder to do on the web. I'm using PHP (not ASP).

Has an开发者_高级运维yone had any experience with writing this kind of thing on web? I'm open to JS etc if needs be. I've seen a couple of hacks for PHP, but would like to know anything more suited.


Dictionary from Python can be compared to associative arrays in (or, less probable, objects) PHP and simple objects (with similar notation as in Python, called JSON) in JavaScript, if you asked for that.


Data structures could be saved as an array;

$car1 = array( 'make' => 'Honda', 'model' => 'Accord', 'colour' => 'Red' );

Or you could make an object;

class cars{
    private $make;
    private $model;
    private $colour;

    public function __construct($make, $model, $colour)
    {
        $this->make = $make
        $this->model = $model;
        $this->colour = $colour;
    }
}

$car1 = new cars('Honda', 'Accord', 'Red');

Or you save it an a database. Or as an YAML and/or JSON document. Or as an XML document.

All depending on what and how much data you have.


You could store it as a PHP array:

$car = array(
    'make' => 'Honda',
    'model' => 'Accord',
    'colour' => 'Red'
);


That looks like a regular associative array to me

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜