N
N
newaitix2015-12-07 12:01:54
PHP
newaitix, 2015-12-07 12:01:54

How can this code be simplified?

$bc=1;
$kf=2;
$gr=3;
$a=Array($bc,$kf,$gr);
$b="A$a[0]B$a[1]C$a[2]D";

Are there ways to not write $a[0],$a[1],$a[2] but put some kind of label in the text, well, let's say
"A%B%C%D"
php will put the elements in the appropriate places array?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cat Anton, 2015-12-07
@newaitix

$b = sprintf('A%dB%dC%dD', $bc, $kf, $gr);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question