PHP code articles (seven) - PHP and MySQL already used functions

A, PHP commonly used functions

// array to a string 
$ = STR The implode ( ' , ' , $ device_string); 

// string transfer array 
$ ARR = the explode ( ' , ' , $ device_string); 

// encoded according to RFC 3986 pair of the URL 
$ STR = rawurlencode (STR $); 

// for URL decoding the encoded string 
$ = STR rawurldecode (STR $); 

// replace string 
$ Content = str_replace ( " <IMG the src = " , "" , $ Content); 

// delete the end of the string ',' character 
$ = RTRIM Content (Content $, " , " ); 

// insertion of one or more units at the beginning of the array
array_unshift ($ Queue, " Apple " , " Raspberry " ); 

// two decimal places without rounding, $ num = 3.149, the result 3.14 
$ new_num = Floor ($ NUM * 100 ) / 100 ; 

// rounded, $ n = 3.14899, result 3.15 
$ new_num = round ($ n-, 2 );

Two, MySQL common operation

// reservations two, rounding the end, result =  100.34 
the SELECT  TRUNCATE ( 100.3465 , 2 )

 

Guess you like

Origin www.cnblogs.com/camg/p/11635135.html