function first() {
foreach($list as $item ) {
${'variable_' . $item->ID} = $item->title;
// gives $varible_10 = 'some text'; (10 can be replaced with any number)
}
$ordinary_variable = 'something';
}
How to get values of this function inside an another function?
Like:
function second() {
foreach($list as $item ) {
get ${'variable_' . $item->ID};
// getting identical value from first() function
}
get $ordinary_variable;
}
- We know that
$variable_id
(id is numeric) already exists infirst()
$list
is anArray()
, which can have more than 100 values.$ordinary_variable
is a string.
Thanks.