Reputation: 18353
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 anyone 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.
Upvotes: 0
Views: 565
Reputation: 1273
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.
Upvotes: 2
Reputation: 137420
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.
Upvotes: 2
Reputation: 5848
You could store it as a PHP array:
$car = array(
'make' => 'Honda',
'model' => 'Accord',
'colour' => 'Red'
);
Upvotes: 1