Like
$args = (
'var1' => 'abc',
'var2' => 'def',
);
$text = sprintf('first var is: %1$s, second one is: %2$s', $args);
Basically the $args variable is dynamic, I don't know if it will have any entries or how many.
The text too, I don't know if it will require variables to be replaced in it, or how many.
How can I make a function like this, that somehow extracts the elements and replaces them in the text if stuff like %s %d, %1$s etc is present?