Hi guys,
All my attempts to dynamically call STR_PAD_BOTH failed as you can see below.
Only the last version, the untouched one, works.
So, is it really impossible???
All my attempts to dynamically call STR_PAD_BOTH failed as you can see below.
Only the last version, the untouched one, works.
So, is it really impossible???
Code:
$string = "BOTH";
echo str_pad("some text", 25, "-", STR_PAD_{$string}) . "<br />";
// returns Parse error: parse error, unexpected '{'
echo str_pad("some text", 25, "-", STR_PAD_ . $string) . "<br />";
// returns ----------------some text
echo str_pad("some text", 25, "-", "STR_PAD_" . $string) . "<br />";
// returns ----------------some text
$string = "STR_PAD_BOTH";
echo str_pad("some text", 25, "-", $string) . "<br />";
// returns ----------------some text
echo str_pad("some text", 25, "-", STR_PAD_BOTH) . "<br />";
// returns --------some text-------- ( expected result )