I got variable
$test = "test1<br />
$test = "Ptest1<br />
You can use a regex to loop through the string and add your value.
$arr = "test1<br /> test2<br /> test3"; echo preg_replace('/^(\h*)([A-Za-z])/m','$1P$2',$arr);
/s are delimiters telling where the regex starts and ends.
m modifier makes the
^ match at the start of each line.
\h* is any amount of whitespace before an alpha character (you can add to that character class if other characters should also be allowed).
To allow the line to start with numbers as well try: