Question: Here is my situation, let's say i have two variables:

```
$a = "Peter";
$b = "tall";

```

Then, i can combine this by

```
$c = " $a is very $b ";

```

which give me the string : "Peter is very tall"

However, if i have another variable $e passed to my function, and the string is " $a is very $b "
then, i print out $e, it just show me " $a is very $b ";

What i expected is "Peter is very tall", because $e is equal to $c.

This is the whole logic flow:

```
$e = " $a is very $b ";
getMsg($e);
function getMsg($e){
  $a = "Peter";
  $b = "tall";
  $c = " $a is very $b ";
  echo $c //Peter is very tall
  echo $e //$a is very $b
}

```

How can i achieve this function?

Answer: 
You could use `sprintf` [sprintf documentation](https://www.php.net/manual/en/function.sprintf.php). The `%s` symbols are string tokens that get substituted in the format string (the 1st param to sprintf).

```
$e = "%s is very %s";
getMsg($e);
function getMsg($e){
  $a = "Peter";
  $b = "tall";
  echo sprintf($e, $a, $b);
}

```

Or a less coupled version of the `getMsg()` function:

```
function getMsg($msg,$name,$is){
  echo sprintf($msg, $name, $is);
}  
getMsg("%s is very %s", "Peter", "tall");

```
Try this. It should work fine. You need to Define `$a` and `$b` outside the function. 

```
function getString($a,$b,$e){

  $c = " $a is very $b ";
  echo $c;
  echo '<br/>'.$e;
}
$a = "Peter";
$b = "tall";
$e = " $a is very $b ";
$response = getString($a,$b,$e);

```

**OUTPUT :** 

```
Peter is very tall 
Peter is very tall

```