PHP loop A string processing solution idea

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.