I
I
Ilya Parshakov2018-05-14 19:49:34
PHP
Ilya Parshakov, 2018-05-14 19:49:34

How to process such a string and write data to a variable?

Hello! Please help, is it even possible to do this?
For example, there is a variable, it contains the text:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sollicitudin augue rutrum metus molestie laoreet. Praesent vulputate at erat quis tincidunt. Vivamus pretium diam sed euismod tempor.
[marker]
Quisque pretium efficitur purus, interdum pulvinar nunc viverra ac. Vestibulum sit amet lobortis ligula. Nulla a nunc eu risus faucibus auctor non at leo. Mauris fermentum, turpis eu feugiat semper, nulla turpis venenatis dui, at condimentum sapien ligula eget ante. Donec vulputate tristique rhoncus. Sed et volutpat elit, ut sollicitudin nibh.

Interested in 2 questions:
1. How to cut the text to the label [marker] and write it to a variable?
2. How can I find the [marker] and cut it out by writing the text to a variable, without this [marker] ?
Thanks in advance for your help and attention!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stimulate, 2018-05-14
@parschakov

//1
$array = explode('[marker]', $var);
echo $array[0];
//2
$var = str_replace('[marker]', '', $var);
echo $var;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question