How to find a word through the cycle?

Hello! Can I find the word thus:
For example: There is text: hi how are you? I'm good, how about you?
And word:
In this case, in both sentences there is a word like(i.e., just 2).
Is it possible to make a condition if more than 1, then begin a loop that takes the first word from the text and puts after the word "as". If such is not present, then takes the second word and so on until you get to "how are you"?
I.e. it should look like: Hello How(not) as as(not) how things(have).
June 5th 19 at 21:56
2 answers
June 5th 19 at 21:58
June 5th 19 at 22:00
I understand You need to first split the string into sentences. For example the "?", to do this pick
php.net/manual/ru/function.explode.php
and then in a loop to check if each individual sentence the word "as" and consider its occurrence, for it has
php.net/manual/ru/function.substr-count.php

And in General, to ask questions, to put it mildly , not yours. Try yourself in music )))) Very difficult to understand what You want to achieve and why. of course also links You gave by formula, and distribute something about php, but in General he's right. Should read about php, at least a little bit.
This proposal has been written to the array, I just don't know how to do above written.

PS I know what I want. - isaac_Harv commented on June 5th 19 at 22:03
I have thrown everything you need for this task: the manual for cycles and branches, a description of the line in principle, and functions available for working with strings. - chaz commented on June 5th 19 at 22:06
I know about the cycles, I just don't know how to take turns to insert words from the text before the word "as". - isaac_Harv commented on June 5th 19 at 22:09
, php.net/manual/ru/function.preg-split.php the first example. - chaz commented on June 5th 19 at 22:12
PS I know what I want

it remains only to tell us about it
I know about the cycles, I just don't know how to take turns to insert words from the text before the word "as".

Well, so would asked. The most primitive way:

$my_string = 'Bob, what are you Smoking?';
$search = 'something';
$replace = 'I know';
$full_replace = $replace . $search;
echo str_replace($search,$full_replace,$my_string);
- Henderson_Beat commented on June 5th 19 at 22:15

Find more questions by tags PHP