I've this config.php file that contains this example array:
return [
myarray => [
'foo' => 'bar_'.str_random(5).'.log'
]
]
I'd like to assign the str_random(5) into a $var variable and use it all in one step; for example, something like (this example doesn't work):
return [
myarray = [
'foo' => 'bar_'.(($var=str_random(5)) && $var).'.log'
]
]
The output should be:
echo $var;
uoEUu
print_r($myarray);
[
'foo' => 'bar_uoEUu.log'
]
Thank you
EDIT
Ok, I found this solution, but It doesn't like me:
return [
myarray = [
'foo' => 'bar_'.$var=str_random(5).''.$var.'.log'
]
]
any cleaner suggestions?
$varbefore creating the array and just use it in the array.return [ myarray = [ 'foo' => 'bar_'.(($var=str_random(5)) && $var).'.log' ] ]str_randomis / does, the&& $varmay be unneeded, and is the bit that means that $var is a boolean, so you're concat-ing a bool to a string which appears to not be what you want.