Hello,
I am trying to get a string and then replace each {NO} where NO is a number
For example the string I am replacing
You have {0} steps left {1} {2} {3}
The function I am parsing it through
public static function parse($string, $array = array())
{
if(empty($array))
{
return $output;
}
for($i=0;$i<count($array);$i++)
{
$output = str_replace('{'.$i.'}', $array[$i], $string);
}
return $output;
}
The PHP echo
echo Lang::parse($lang['quest']['steps_left'], array('3', '2', '3'));
What is turns out to be
You have {0} steps left {1} 3 {3}
Any help? Simply it needs to replace all {NUMBERS} with the array so {0} would be 3 {1} would be 2 other solutions to make the function smaller will also be appreciated
Thanks in advance