Hey everyone, so I have this problem when im coding my bot.
Its PHP, OOP, have several public functions and one of them is getting rather large, the function creates a new object, and assigns it to a variable, variable name is generated from array
${$array[$pocket][0]} = new blah();
now when I do that, its fine because its all one big function, however if I want to divide this into small functions, I cant access these variables from other functions, im guessing because I dont import them as globals, but how do I import them as globals? hope thats quite explanatory, heres quick mock up of what im trying to do
just a quick mock up...
Its PHP, OOP, have several public functions and one of them is getting rather large, the function creates a new object, and assigns it to a variable, variable name is generated from array
${$array[$pocket][0]} = new blah();
now when I do that, its fine because its all one big function, however if I want to divide this into small functions, I cant access these variables from other functions, im guessing because I dont import them as globals, but how do I import them as globals? hope thats quite explanatory, heres quick mock up of what im trying to do
PHP:
class test {
public function connect () {
foreach($this->accs as $key => $value) {
${$value[$key][0]} = new whatever();
}
}
public function post () {
foreach($this->accs as $key => $value) {
//this wont work...
${$value[$key][0]}->post();
}
}
}
just a quick mock up...