I have a string, where user can add special mark, for example [include=example_file] and I would like to include "example_file.php" to the place where the mark is.
User's text can be like:
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industrys standard dummy text ever since the 1500s.
[include=contact_form] // here should be contact_form.php included
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industrys standard dummy text ever since the 1500s
I use this, to echo user's text, now:
<?php echo $this->view['users_text']; ?>
... and new output should be like:
<?php
// echo first paragraph
include "contact_form.php";
// echo second paragraph
?>
What is the simplest way how to include files finded in those special marks?
str_replace('[include=contact_form]', file_get_contents(....), $this->view['users_text'])or explode on the string and then echo part 1, include file, echo part 2[include=../../../../../etc/passwd]preg_splitifcontact_formis variable.