<?php
class Table {
//an associative array of the fields from your db
var $fields = array();
//the prefix for the fields
var $prefix = "your_prefix_";
public function __get($name) {
if (!array_key_exists($name, $this->fields) && array_key_exists($this->prefix . $name, $this->fields)){
return $this->fields[$this->prefix . $name];
}
}
}
//$your_array is the array of fields from your database
$your_table = new Table();
$your_table->fields = $your_array()
#the field name from the orginal array minus the prefix
echo $foo->field_name;
?>