PHP loop processing of a string-php Tutorial

Source: Internet
Author: User
PHP loops a string for processing. I want to do this. there is a string str & quot; 1, 3, 5, 6, 8, 9 & quot; the data in this string is ID, I want to loop them out one by one and bring them into the query statement for separate queries. although it is very simple, I just got started with php and don't know how to use it. please write the complete code. thank you, i'm Cainiao ------ solution ------------------ PHPcode $ str PHP loop a string for processing
I want to do this
There is a string str = "1, 3, 5, 6, 8, 9 ";

The data in this string is ID. I want to cycle them one by one and bring them into the query statement for separate query.
How to implement it?
Although very simple, I don't know how to use php.
Please write the complete code. thank you. I'm a Cainiao.

------ Solution --------------------
PHP code
$ Str = "1, 3, 5, 6, 8, 9"; $ str = explode (',', $ str); foreach ($ str as $ k => $ v) {echo $ v."
"; // Your other operations .}
------ Solution --------------------
Explode function. Use google
------ Solution --------------------
Why are people always asking these questions?
I think this is an attitude issue.
At least the manual is usually used to double the character string.
Even if you do not know the built-in functions of php
You can also write an algorithm yourself.
However, it is highly efficient to understand basic common functions.
Ignore me if I have any questions.
------ Solution --------------------
Top floor, very good! Kubernetes
------ 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
Why are people always asking these questions?
I think this is an attitude issue.
At least the manual is usually used to double the character string.
Even if you do not know the built-in functions of php
You can also write an algorithm yourself.
However, it is highly efficient to understand basic common functions.
Ignore me if I have any questions.

------ Solution --------------------
Discussion

Reference:
Why are people always asking these questions?
I think this is an attitude issue.
At least the manual is usually used to double the character string.
Even if you do not know the built-in functions of php
You can also write an algorithm yourself.
However, it is highly efficient to understand basic common functions.
Ignore me if I have any questions.


Although it is a bit radical, it makes sense. it is recommended that you check the manual more.

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.