Answer the question
In order to leave comments, you need to log in
How to read a string in php?
I don’t know how to formulate the question exactly, but it turns out like this: is it possible to achieve in php reading the text in a variable in a row and as it reads, if the condition matches, immediately perform some actions.
Those. how a person, when reading and as he reads, immediately highlights something with a marker or immediately crosses out the unnecessary.
Example 1: if the text contains the word php and after it the word java is found somewhere in the text then... delete the previous word php.
<p>Ох уж этот php хотя java адский ад лучше уж пусть php</p>
<h1>Заголовок</h1> текст <br> текст <h2>Подзаголовок</h2>
Answer the question
In order to leave comments, you need to log in
PHP is a great language in which you can implement almost any algorithm.
In the first case, you can use the explode function with a space delimiter, get the output array exactly in the order in which the words appear. And then process the array as you like.
In the second case, you can also use explode, only when iterating through the array, take into account the beginning and end of the header, set the start flag and the end flag of the tag.
All in your hands.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question