当前位置:网站首页>PHP reference manual string (7.2000 words)
PHP reference manual string (7.2000 words)
2022-04-23 19:31:00 【Your brother's way of programming (love sharing)】
<?php
$str=addcslashes("A001 A002 A003","A");
echo($str);// In uppercase A Put a backslash in front of \, Case sensitive
<?php
$str = "Welcome to Shanghai!";
echo $str."<br>";
echo addcslashes($str,'A..Z')."<br>";// There's capital A To Z Add a backslash in front of all the English between \
echo addcslashes($str,'a..z')."<br>";
// There are lowercase a To z Add a backslash between all \
echo addcslashes($str,'a..g');// Lowercase a To g This range is all added with a backslash \
<?php
$str=addslashes('Shanghai is the "biggest" city in China.');// Only the quotation marks within single quotation marks or double quotation marks are added with backslashes
echo($str);
<?php
$str = "Who s' Bill Gates?";
echo addslashes($str);// Only quotation marks within single quotation marks or double quotation marks have backslashes
?>
<?php
$str=bin2hex("Shanghai");
echo($str);//Shanghai Convert to hex
<?php
$str=bin2hex("Shanghai");// Convert to hex
echo "<br />";
echo pack("H*",bin2hex("Shanghai"));// Restore the original data
<?php
$str = "Hello World!";
echo chop($str,"World!");// Remove $str In variables World
<?php
$str = "Hello World!\n\n";
echo $str."666";
echo "<br />";
echo chop($str)."666";// Remove \n\n
<?php
echo chr(61);// The decimal system stands for ascll code
echo "<br />";
echo chr(061);echo "<br />";// Octal stands for ascii code
echo chr(0x61);echo "<br />";// Hexadecimal stands for ascii code
<?php
$str = "Shanghai";// The string is divided into characters one by one S h a n g h a i, After split , Add... To the split position .
echo chunk_split($str,1,'.');
<?php
$str = "Shanghai";// Split after every six characters , After split , Add... To the split position ... If chong Less than six , Just put ... Add last
echo chunk_split($str,6,'...');
<?php
$str = ",2&5L;&\@=V]R;&0A `";
echo convert_uudecode($str);// decode
<?php
$str = "Hello world!";
$encodeString = convert_uuencode($str);// Encoding is equivalent to encryption
echo $encodeString . "<br>";
<?php
$str = "PHP is pretty fun!!";
$strArray=count_chars($str,1);// Model a ,ASCII The value is the key name ( character ), The number of occurrences is the key value ( The number of times characters appear ):
foreach ($strArray as $key => $value) {
echo " character <b>'".chr($key)."'</b> Found $value Time .<br>";
}// How many times does each character appear ,chr The function representative shows ascii code
<?php
$str = crc32("Shanghai");
printf("%u\n",$str);// You don't understand what I mean?
?>
<?php
$str = "Hello world. I love Shanghai!";
print_r(explode(" ",$str));//( Split a string into arrays , Divide the space into lines )
<?php
$str = 'one,two,three,four';
print_r(explode(",",$str,0));
// Split a string into arrays . Split into only one array element
<?php
$str = 'one,two,three,four';
print_r(explode(",",$str,-1));
//-1:four Don't , Replace the previous string with , Division , Into array elements
<?php
$number = 9;
$str = "Beijing";
$file=fopen('test.txt','w');// Write mode , open test.txt file
echo fprintf($file,"%u %s",$number,$str);// Put the numbers $u character string $s Write to test.txt In the document
<?php
print_r(get_html_translation_table());// The most common code
<?php
echo hebrev("? ???? ?????");// In the opposite direction
<?php
echo hebrevc("? ???? ?????\n? ???? ?????");// hold \n convert to <br>
<?php
echo hex2bin("48656c6c6f20576f726c6421");
// Convert hexadecimal values to ascii code
<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars($str);// Original output
echo "<br />";
echo htmlspecialchars_decode($str);// Parse and output the special characters in the string
?>
<?php
$arr = array('Hello','World!','I','love','Shanghai!');
echo implode(" ",$arr);// The array becomes a string , Divide the space into lines
<?php
$arr = array('Hello','World!','I','love','Shanghai!');
echo join(" ",$arr);//implode Another name for
<?php
echo lcfirst("WWWello world");// Turns the first character in a string to lowercase
<?php
echo levenshtein("Hello World","ello World");
echo "<br />";
echo levenshtein("Hello World","ello World",10,20,40);// Can't
<?php
$str = "Hello World!";
echo $str . "<br>";
echo ltrim($str,"Hello");// Remove from the left side of the string $str Inside Hello These strings ,ltrim($str) Words . Yes, remove the space on the left
<?php
$str = "Shanghai";
echo md5($str);// encryption , No change
<?php
$str = "Shanghai";
echo md5($str,TRUE);// original 16 Character binary format
<?php
$filename = "test.txt";
$md5file=md5_file($filename);
echo $md5file;// File encryption , Does not change with refresh
<?php
echo metaphone("hello");// pronunciation
<?php
echo "One line.\nAnother line.";
echo "<br/>";
echo nl2br("One line.\nAnother line.");// stay \n Insert line break before
<?php
echo number_format("5000000");
echo "<br />";
echo number_format("5000000",2);// Keep two decimal places
<?php
$num = 4999.9;
$formattedNum = number_format($num)."<br>";// rounding
echo $formattedNum;
$formattedNum = number_format($num, 2);// Keep two decimal places , Don't go into rounding
echo $formattedNum;
?>
<?php
echo ord("S");// a key : Of the first character ascii Code value
// return S Of ascii Code value
<?php
parse_str("name=cyg&zge=60");
echo $name.$zge;// This function takes = The one on the left becomes a variable , On the right is the value of the variable . Use... Between multiple variables & Connect
<?php
parse_str("name=cyg&zge=60",$my);
print_r($my);//$my It means to become an array . such as name=cyg&zge=60 When it becomes an array Array ( [name] => cyg [zge] => 60 )
<?php
$num1 = 123456789;
$num2 = -123456789;
$char = 50; // ASCII character 50 yes 2
// notes : Format value "%%" Return the percent sign
printf("%%b = %b <br>",$num1); // Binary number
printf("%%c = %c <br>",$char); // ASCII character
printf("%%d = %d <br>",$num1); // Signed decimal numbers
printf("%%d = %d <br>",$num2); // Signed decimal numbers
printf("%%e = %e <br>",$num1); // Scientific enumeration ( A lowercase letter )
printf("%%E = %E <br>",$num1); // Scientific enumeration ( Capitalization )
printf("%%u = %u <br>",$num1); // Unsigned decimal numbers ( just )
printf("%%u = %u <br>",$num2); // Unsigned decimal numbers ( negative )
printf("%%f = %f <br>",$num1); // Floating point numbers ( Depending on local settings )
printf("%%F = %F <br>",$num1); // Floating point numbers ( Regardless of local settings )
printf("%%g = %g <br>",$num1); // Shorter than %e and %f
printf("%%G = %G <br>",$num1); // Shorter than %E and %f
printf("%%o = %o <br>",$num1); // Octal number
printf("%%s = %s <br>",$num1); // character string
printf("%%x = %x <br>",$num1); // Hexadecimal number ( A lowercase letter )
printf("%%X = %X <br>",$num1); // Hexadecimal number ( Capitalization )
printf("%%+d = %+d <br>",$num1); // Symbol specifiers ( just )
printf("%%+d = %+d <br>",$num2); // Symbol specifiers ( negative )
?>
<?php
$str = "I=0Alove=0AShanghai!";
echo quoted_printable_decode($str);// analysis ascii code .
// for instance ,=0A Represents a space
<?php
$str = "Hello world. (can you hear me?)";
echo quotemeta($str);// Metacharacters are preceded by backslashes ( Metacharacters are characters of regular expressions )
<?php
$str = "Hello World!";
echo rtrim($str,"World!");// Get rid of $str Dexter World!
<?php
$str = "Shanghai";
echo sha1($str);// Refresh several times without changing
<?php
$str = "Shanghai";
echo sha1($str,true);// original 20 Character binary format
<?php
$filename = "test.txt";
$sha=sha1_file($filename);// Encrypt the file
echo $sha;
<?php
echo similar_text("Hello World","Hello Shanghai");
// The similarity between two strings is 6, Including Spaces . from 1 Here we go
<?php
similar_text("Hello World","Hello Shanghai",$percent);
echo $percent. "%";// Similarity degree % percentage
// The similarity between two strings is 6, Including Spaces . from 1 Here we go
<?php
$number = 2;
$str = "Shanghai";
$txt = sprintf("There are %u million cars in %s.",$number,$str);
echo $txt;//%u It's the number. %s Is string
?>
<?php
$str = "age:30 weight:60kg";
sscanf($str,"age:%d weight:%dkg",$age,$weight);// Input
// Display type and value
var_dump($age,$weight);
<?php
echo str_ireplace("WORLD","Shanghai","Hello world!");
// Case insensitive , Put the... Of the third parameter WORLD Replace with Shanghai
<?php
$arr = array("blue","red","green","yellow");
print_r(str_ireplace("RED","pink",$arr,$i));// stay $arr Function , hold red Replace with pink. Case insensitive . The number of replacements is 1 individual
echo " Replacement number :$i";
<?php
$str = "Hello World";
echo str_pad($str,30,'.');// A total of thirty characters , Not enough . fill
<?php
$str = "Hello World";
echo str_pad($str,30,'.',STR_PAD_LEFT);// A total of thirty characters , Not enough . fill ( On the left )
<?php
$str = "Hello World";
echo str_pad($str,30,'.',STR_PAD_BOTH);// A total of thirty characters , Not enough . fill ( Both sides )
<?php
echo str_repeat("Shanghai",5);// Fill Shanghai five times
<?php
echo str_replace("world","Shanghai","Hello world!");// Case sensitive . Put the... Of the third parameter world Switch to shanghai
<?php
echo str_rot13("I love Shanghai");// code
echo "<br>";
echo str_rot13("V ybir Funatunv");// decode
<?php
echo str_shuffle("I love Shanghai");// Randomly scramble strings . The refresh effect is different
<?php
print_r(str_split("Shanghai"));// Turn a string into an array . Every character is an element
<?php
print_r(str_split("Shanghai",3));// Turn a string into an array . It can be divided into three elements
<?php
echo str_word_count("I love Shanghai!");// The number of words is three
<?php
print_r(str_word_count("I love Shanghai!",1));// The number of words is three , Turn a string into an array
<?php
print_r(str_word_count("I love Shanghai!",2));// The number of words is three , Turn a string into an array , The key name is the position of the subscript
<?php
print_r(str_word_count("I love Shanghai & good morning!",1));
print_r(str_word_count("I love Shanghai & good morning!",1,"&"));
// This means to put & Treat as a word
?>
<?php
echo strcasecmp("shanghai","SHANGHAI");
// Output 0 For equality . Case insensitive
<?php
echo strcasecmp("Hello world!","HELLO"); //
// Case insensitive .( When there are many first parameters ) In contrast . Positive numbers
echo "<br />";
echo strcasecmp("Hello world!","HELLO WORLD! HELLO!"); // string1 Less than string2
// Case insensitive . The space is also called .( When there are many second parameters )
/// In contrast , negative .
<?php
echo strchr("Hello world!","world");
// See where the second parameter appears in the first parameter , And output all the following characters
<?php
echo strchr("Hello world!","world",true);// return world Where the first parameter appears 、. Returns only the first character
<?php
echo strcmp("Hello world!","Hello world!");// Is case sensitive as like as two peas? , Just go back 0
<?php
echo strcmp("Hello world!","Hello world!"); // Two strings are equal 0
echo strcmp("Hello world!","Hello"); // string1 Greater than string2:7( Positive numbers )
echo strcmp("Hello world!","Hello world! Hello!"); // string1 Less than string2:-7( negative )
<?php
echo strcspn("Hello world!","w");
//w Position in parameter 1 . from 0 Start counting
<?php
echo strip_tags("Hello <b>world!</b>");// Get rid of html label
<?php
echo strip_tags("Hello <b>world!</b>","<b>");// Get rid of html label , But you can use <b>
<?php
echo stripcslashes("Hello \World!");// Remove the backslash
<?php
echo stripslashes("Who\'s Bill Gates?");// Remove backslash \
<?php
echo stripos("You love php, I love php too!","PHP");//PHP The position of the first occurrence in the first parameter , from 0 Start counting
版权声明
本文为[Your brother's way of programming (love sharing)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231929018583.html
边栏推荐
- Golang timer
- The flyer realizes page Jump through routing routes
- ESP8266-入门第一篇
- Speculation on the way to realize the smooth drag preview of video editing software
- Virtual machine performance monitoring and fault handling tools
- Scrum Patterns之理解各种团队模式
- The difference between underline and dot of golang import package
- Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
- [报告] Microsoft :Application of deep learning methods in speech enhancement
- Video understanding
猜你喜欢
Class loading process of JVM
精简CUDA教程——CUDA Driver API
Lottery applet, mother no longer have to worry about who does the dishes (assign tasks), so easy
php参考手册String(7.2千字)
@MapperScan与@Mapper
An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary
【webrtc】Add x264 encoder for CEF/Chromium
Intuitive understanding of the essence of two-dimensional rotation
优先使用组合而不使用继承
NiO related Basics
随机推荐
Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
Coordinate conversion WGS-84 to gcj-02 and gcj-02 to WGS-84
MySQL syntax collation (4)
MFC obtains local IP (used more in network communication)
Deep learning -- Summary of Feature Engineering
Matlab 2019 installation of deep learning toolbox model for googlenet network
antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
C6748 software simulation and hardware test - with detailed FFT hardware measurement time
Build intelligent garbage classification applet based on Zero
The difference between underline and dot of golang import package
【webrtc】Add x264 encoder for CEF/Chromium
MFC获取本机IP(网络通讯时用得多)
Kubernetes入门到精通-在 Kubernetes 上安装 OpenELB
Main differences between go and PHP
Unity创建超写实三维场景的一般步骤
2021-2022-2 ACM集训队每周程序设计竞赛(8)题解
Kubernetes getting started to proficient - install openelb on kubernetes
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
考试系统进入试卷优化思路
An example of using JNI to directly access surface data