Skip to content

Instantly share code, notes, and snippets.

@jeffstephens
Created March 24, 2016 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffstephens/9ddcd03d8114e3ba296a to your computer and use it in GitHub Desktop.
Save jeffstephens/9ddcd03d8114e3ba296a to your computer and use it in GitHub Desktop.
<?php
class MachineDescription {
public $name, $type;
public function __construct($name, $type) {
$this->name = $name;
$this->type = $type;
}
}
$query_result = mysqli_query(); // whatever you need to query
$machines = [];
foreach($row in mysqli_fetch_assoc($query_result)) {
$machines[] = new MachineDescription($row['name'], $row['type']);
}
return json_encode($machines);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment