PHP loop processing of a string
I'm going to do this.
There is a string str = "1,3,5,6,8,9";
The data in this string is the ID, I want to loop them out one by one, and bring it into the query statement alone.
How did it come true?
Although very simple, but just contact PHP do not know how to use
Please write the complete code, thank you, I am a rookie
------Solution--------------------
PHP Code
$str = "1,3,5,6,8,9"; $str = Explode (', ', $str); foreach ($str as $k + = $v) {echo $v.
"; Your other actions. }
------Solution--------------------
Explode function, specifically using Google
------Solution--------------------
I don't know how people always ask these questions.
I think it's a matter of attitude.
At least the manual turned over the string more commonly used double
Even if you don't know the function that PHP comes with
You can solve it by writing an algorithm yourself.
But it's better to understand the basic common functions.
If you think I've got a problem with that, ignore me.
------Solution--------------------
Top floor, very good! Crazy Top
------Solution--------------------
$arr = Explode (",", $string);
foreach ($arr as $value) {
Echo $value;
}
------Solution--------------------
PHP code
foreach (Explode (', ', $str) as $k = + $v) {echo "{$k} : {$v}
\ r \ n ";}
------Solution--------------------
discussion
I don't know how people always ask these questions.
I think it's a matter of attitude. Code Manual Rollover string comparison commonly used to double the
even if you do not know the PHP own function
to write an algorithm can also solve the
but still understand the basic commonly used functions such efficiency will be high
think I said there is a problem, ignore me.
------Solution--------------------
discussion
References:
I don't know how it's always been asked. Question
I think it's an attitude problem
at least the manual rollover string more commonly used to double the
even if you do not know PHP's own function
to write an algorithm can also solve the
but still understand the basic commonly used functions such efficiency will be high
sleep If there's something wrong with me, ignore me.
Although there are some extreme, but there is a reason, it is recommended that landlord more check manual