So i recently picked up on a project that i put off for a year, due to some personal issues; and have come back to it, only to then realize that i was dealing with a btch of an issue.
In my custom templating class i have this function that takes a certain set of custom variables such as:
session.member.username and this.user
when i use these, they work fine but i also want to incorporate an "array" type structure.
session.member[username] and this.form[name]
But it just doesnt want to work, and gives me an error. I dont know to much about regex and havent really found any good tutorials or examples pertaining even closely to what I'm trying to achieve.
Essentially i want to have object types, and arrays.
So as to be able to have a different use between the two.
Ex😮bjects; classname.object.item
Arrays; classname.array[item]
More than likely im going to reserve the classname.array[item] for local variables whereas the classname.object.item would be globalized to the "core global" functionality.
This is my code, so far;
function eval_vars($str){
$sessi =& new sessions;
$type = explode('.',$str[1]);
$e_var = "<span style=\"color:red; text-decoration:strike-through;\">(<strong>{$type[0]}.{$type[1]}</strong>)</span>";
$v_obj = $type[1];
// Match arrays { array_var[key]; }
if(preg_match_all("#(?i)(.*?)#xmi", $str[0] , $type[1])){
switch($type[0]):
case 'session':
//$sessi->member['rank'] = "10";
return $sessi->member[$v_obj];
//return {$sessi->member[]}[$v_obj]";
continue;
break;
case 'core':
return $sessi->member[$v_obj];
continue;
break;
case 'lang':
return $gcmsclass->lang[$v_obj];
continue;
break;
case 'this':
return $_this->$v_obj;
continue;
break;
default:
return $e_var;
continue;
break;
endswitch;
// Match objects { $type->object }
}
}
Any help in this matter would be greatly appreciated.