length$STR 7= ' My Pleasure,sir ';//substr ($str, $a, $b) intercepts the string, $a represents the position at which the Intercept begins, $b represents the Intercept lengthEcho substr($STR 7, 3,8), ' ; Echo substr($STR 7, 2,8), ' ; Echo substr($STR 7, 3), ' //$b do not write, the default intercept to the lastEcho substr($STR 7, 3,-2), ' //$b is negative, it will be truncated to the B-th characterEcho substr($STR 7, -3), ' ; Echo substr($STR 7, -3,2), ' //The $a is a negative number, and a is a
Title: Convert a string 1234567890 to 1,234,567,890Solution One: The two strings in reverse view will be 0987654321 converted to 098,765,432,1, then you can 0987654321 The array (098,765,432,1) is divided into three length strings, then the array and comma are combined into a string and then reversed to get the final result .$str= ' 1234567890 ';functionChange$str){ $str 1=Strrev($str);//reverses the string first $arr=Str_split($str 1, 3);//array that is split into 3 for each cell st
Php query voting exercises (0508), php0508
Exercise questions:
Solution:
Method 1:
1. Voting homepage:
3. Create a database access class and encapsulate it for reference:
Method 2:
1. Voting homepage:
2. process the voting page:
3. view the voting result page:
Webpage display result:
PHP Exercises (II.)
Program 6.title: Suppose someone has 100,000 of cash, every intersection need to pay the rules for the payment when he is more than 50,000 per cent of the amount of cash to be 5, if the cash is less than or equal to 50,000 per 5,000. Ask how many times this person can pass this intersection.
1 $money= 100000;2 $i= 0;3 while($money>= 5000) {4 if($money> 50000) {5 $money*= 95
Because it is also the way of learning, first draw ideas, code and look at the learning of others, the final is based on the idea of completion, may be relatively simple, late in to improve and changeThe above is a simple classSend a successfulIn the process of writing a few problems encountered, according to the URL of the request is not the same, the request header stitching also needs to change, here the requested URL is http://www.cnblogs.com/mvc/PostComment/Add.aspx static connection, all p
/*Suppose someone has 100000 in cash. A fee is required for each intersection. The payment rule is to pay 5% when he has more than 50000 cash, if the cash is less than or equal to 50000 per 5000. Please write a procedure to calculate how many times this person can pass the junction.*/$money = 100000;for ($i =0; $money >=5000; $i + +) {if ($money >=50000) {$money = $money-$money *0.05;}else if ($money >=5000) {$money-= 5000;}}Echo ' This guy can go ', $i, ' times/*hundred dollars to buy hundred c
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.