PHP implementation of the number format, the number of three-bit comma function function, the specific code is as follows:
function Num_format ($num) {
if (!is_numeric ($num)) {return
false;
}
$num = Explode ('. ', $num);/to separate integers and decimals
$rl = $num [1];//Fractional part value
$j = strlen ($num [0])% 3;//integer number
$SL = substr ($ Num[0], 0, $j)//Before the number of three digits out
$SR = substr ($num [0]
It refers to the echo string, which is better than the connection. The reason is not to say, first look at the following two sentences
What was the result?
1+5=6?
1+5=6?
——————
6?
2?
——————
6.6?
6.6?
——————
I can only say echo ' 5+1= '. The result of 1+5 is 10, so the result is 6 and 2.
Why is it so. Is there no Exchange law for addition in PHP?Let's not think about why. If I change the number above to a comma, try it.
|+----+--------+------------+| 1 | 20 | red || 2 | 20 | blue || 10 | 30 | pinkpurple |+----+--------+------------+3 rows in set (0.00 sec)Note that the last set of values, (' Pink ' purple ') is missing a comma, so the query results are interpreted by default as ' Pinkpurple ' strings.Mysql> SELECT * from my_table where mod_name = (' Pink ' purple ') +----+--------+------------+| ID | mod_id | Mod_name |+----+--------+---
commas, hereinafter referred to as N;Loop {Judging by ID: IN {Gets the data closest to the first comma, which is Substring_index (Substring_index (A.username,',', b.help_topic_id+1),',',-1) I=I+1} ID=Id+1 }Summarize:The disadvantage of this approach is that we need a separate table with sequential numbers (here is incre_table). and the maximum value of a continuous series must be greater than the number of values that match the split. Of course, MySQ
Tags: ref not www post img GUID nec comma valueThe requirement is that the values stored in a field in a table are separated by commas, requiring that the data be traced against each of the separated values, but not using a like query.The data is this:The SQL for the query is as follows:SELECT * FROM (
select GUIDs, Regexp_substr (st_responsible, ' [^,]+ ', 1, level) responsible from
Tt_cancle_ Responsible
connect by Level The qu
Get ready:Cat Test.txt 1 3 4Example:Cat Xargs 1 3 4You can see that the resulting string is separated by a space.Separate the above string with a comma, you can use the TR command to replace the spaceCat Xargs TR ' ' ' , 'However, the TR command can only replace a single character, and multiple characters cannot be implemented.Use SED to implement the substitution of multiple strings:Cat Xargs sed /s//','/gSED can replace more than one string, can com
The comma operator in C is a lower-priority operator, used in conjunction with variable initialization and conditional judgment in a for loopA + B, C; The value of this expression is the value of the C variablem = a + B, C; Where the value of the M variable is the value of a plus B, the value of the expression is still the value of the C variablen = m = a + B, C; Where the value of the N and m variables is the value of a plus B, the value of the expre
Recently in the processing of text strings, no row of data are separated by commas, each field value is usually enclosed in double quotation marks, but some field values also contain commas, and even some fields do not have double quotation marks, this is a bit troublesome to split upHere's a look at my solution, if anyone has a better way, welcome to join the discussion O (∩_∩) o~/*** Java string comma split parsing method * This is specifically desi
Question mark comma operator syntax
The code is as follows
Copy Code
$a = 1;$b = $a ==1? ' A ': ' B ';echo $a;Result outputA
Parse the above statement into if else
The code is as follows
Copy Code
$a = 1;if ($a ==1){Echo ' A ';}Else{Echo ' B ';}Result outputA
example, in the application we define the table name based on the parameters that come over
The code is
var New // // for (i = 0; i ) { var spans = "; + = ' ; // $ (' #appointment '). append (spans); } Get the array comma separated in the signal to get inside the data, the last DOM insert page
since GCC 2.5, but GCC is still accepted. To initialize a series of elements to the same value, write "[first ... last] = value". This is a GNU extension.
For example: int widths[] = {[0 ... 9] = 1, [10 ... 99] = 2, [100] = 3};If the value has a side effect, this side effect occurs only once, not every time within the range.
Note that the length of the array is the maximum value specified plus one.
Reproduced above from http://zhouyang340.blog.163.com/blog/static/3024095920123495051607/
array
Copy Code code as follows:
Here's some better code:
Copy Code code as follows:
The following is mainly to add a way to remove multiple commas as a comma
Copy Code code as follows:
function Dostr (str) {
Str=trim (str);
var strarry=unique (Str.split (","));
Str=strarry.join (",");
Str=str.replace (/,/ig, ",");
Str=str.replace (/[^0-9,]*/ig, "");
Str=str.replace (New RegExp (', + '
Today in the Web to find an introduction to the substitution of PHP in the string space for the comma ', ' the article, kept a diary.
Copy Code code as follows:
/*
* The space in the keyword is replaced with ', '
*/
Public Function Emptyreplace ($STR) {
$str = Str_replace (', ', $str); Replace full-width space with half corner
$str = Str_replace (', ', $str); Replaces a contiguous space with a
$noe = false; If you encounter a character
Method One:String strtest = strtest.substring (0, Strtest.lastindexof (', '))//Fetch to end of No. 0 subscript and then assigned to string variableMethod Two:
Using System;Using System.Web;
public class Ajaxtestpagehandler:ihttphandler { public void Proce Ssrequest (HttpContext context) { context. Response.ContentType = "Text/plain"; System.Text.StringBuilder sb = new System.Text.StringBuilder ()//Get a StringBuilder object BLL. STATICDATABLL BLL = new BLL. STATICDATABLL (); Sy
1001. A+b Format (+)Time limit MS
Memory Limit 65536 KB
Code length limit 16000 B
Program Standard author CHEN, Yue
Calculate A + B and output the sum in standard format – that's, the digits must be separated to groups of three by COM Mas (unless there is less than four digits).
Input
Each input file contains the one test case. Each case contains a pair of integers a and b where-1000000
Output
For each test case, you should output the sum of A and B on one line. The sum must is written in th
If there is a student student tableThe fields in the Student Table have field course fields with 1,2,3,4,5,6,7 7 coursesCREATE TABLE Student(Name varchar (255),Course varchar (255))INSERT into student (name, course)Values (' Zhang San ', ' 1,2,5,7 ');Question one, judge whether Zhang San chose course 2SELECT * FROMwhere name = ' Zhang San 'and String_to_array (course, ', ') @> array[' 2 ']Question two, judge whether Zhang San chooses the course at the same time 2,6SELECT * FROMwhere name = ' Zha
'; Select name into str from table1 where id = 2; Set cnt = calc_length (str, ', '); drop table if exists table2; Create table2 (id int not NULL, name varchar (255) is not NULL) default Charset=utf8; While I Do Set i = i+1; INSERT into table (ID, name) values (i, split_string (str, ', ', i)); End while; End $$ Method Two: Cartesian Product Realization: Select A.id,substring_index (Substring_index (A.loginname, ', ', b.help_topic_id+1), ', ',-1) From Account A Join Mysql.help_topic b On b.h
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.