Let's say string is:
$str="abcdefg foo() hijklmopqrst";
How do I let php call foo() and insert the returning string to this string?
If you're calling a method of some class, you can use normal variable expansion. For example:
<?php
class thingie {
public function sayHello() {
return "hello";
}
}
$t = new thingie();
echo "thingie says: {$t->sayHello()}";
This will output:
thingie says: hello
Note that the braces around the call are required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With