Home Backend Development PHP Tutorial php知识点温习之字符串

php知识点温习之字符串

Jun 13, 2016 pm 01:15 PM
echo format int str string

php知识点复习之字符串

这些可都是辛辛苦苦敲出来的记得多回头来看看啊一定!!!

/*echo qqqqqq\nqqqqqq
qqqqqqqqqqqqq\rqqqqqqqqqqqqqqqqqq
mark*/
//技术标志要另起一行,并且是顶格写!
//作用跟""类似
//最致命的一点是:mark后面不能有任何符号,就是它必须用在代码的最后部分






$a = "aaaaaaaaaa";
$b = "bbbbbbbbbb";
$c = print($a);


echo "
";
echo $c;
echo "
";
echo $a,$b;


//5b二进制格式;%c ASCII格式
$format = "%b,%c";
printf($format,100,200);
echo sprintf($format,100,200);
echo "
";




$str = "abcdefghijklmnopqrstyvwxyz";
$width = 4;
$break = "\t";
echo wordwrap($str,$width,$break,true);


/*strtoupper();
strtolower();
ucwords();*/


//strlen()
//字符串中的空格也算一个啊


//substr_count(string str,string sub,[int start,int length])的使用
$words = "ran zhang li ni ran ran";
$handle = "ran";
$count = substr_count($words,$handle);
echo $count;




//mixed str_word_count(string $str,[int format,string $child]);
//format 0:默认值,返回单词数目
// 1:返回单词的数组,键是索引值
// 2:返回单词的数组,键是单词首字母的位置




//查找子串
$a1 = "aaaaaabdddddd";
$a2 = "b";
$a3 = strstr($a1,$a2);
echo $a3;
//输出bdddddd




//位置查找,跟上面的几乎一样就是返回的是位置
//int strpos(string $a,string b,[int offset]);






//字符串复制
echo "
";
$input = "zhangran";
$number = 10;
$str = str_repeat($input,$number);
echo $str;




//字符串的反转
echo "
";
$a4 = strrev("abc");
echo $a4;




//替换
//substr_replace(mixed $string,string $replacement,int $start,[int $length])




//切分
echo "
";
$a5 = "hello,world,i,am,the,only,one";
$separator = ",";
$a7 = 3;
$array = explode($separator,$a5,$a7);
print_r($array);


echo "
";
$a8 = "qqqqqqqqqqqqqqqqqq";
$a9 = 4;
$b3 =str_split($a8,$a9);
print_r($b3);
//如果不能被整出的 先以前面的先



//合并
echo "
";
$b4 = array("aaa","bbb","ccc");
$b5 = ",";
echo implode($b5,$b4);


//字符串的比较
//int strcmp(str1,str2)这是完全比较


//strncmp(str1,str2,len)比较两个字符串的前len个字符串是否相等

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Convert basic data types to strings using Java's String.valueOf() function Convert basic data types to strings using Java's String.valueOf() function Jul 24, 2023 pm 07:55 PM

Convert basic data types to strings using Java's String.valueOf() function In Java development, when we need to convert basic data types to strings, a common method is to use the valueOf() function of the String class. This function can accept parameters of basic data types and return the corresponding string representation. In this article, we will explore how to use the String.valueOf() function for basic data type conversions and provide some code examples to

How to convert char array to string How to convert char array to string Jun 09, 2023 am 10:04 AM

Method of converting char array to string: It can be achieved by assignment. Use {char a[]=" abc d\0efg ";string s=a;} syntax to let the char array directly assign a value to string, and execute the code to complete the conversion.

Five selected Go language open source projects to take you to explore the technology world Five selected Go language open source projects to take you to explore the technology world Jan 30, 2024 am 09:08 AM

In today's era of rapid technological development, programming languages ​​are springing up like mushrooms after a rain. One of the languages ​​that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

Use Java's String.replace() function to replace characters (strings) in a string Use Java's String.replace() function to replace characters (strings) in a string Jul 25, 2023 pm 05:16 PM

Replace characters (strings) in a string using Java's String.replace() function In Java, strings are immutable objects, which means that once a string object is created, its value cannot be modified. However, you may encounter situations where you need to replace certain characters or strings in a string. At this time, we can use the replace() method in Java's String class to implement string replacement. The replace() method of String class has two types:

2w words detailed explanation String, yyds 2w words detailed explanation String, yyds Aug 24, 2023 pm 03:56 PM

Hello everyone, today I will share with you the basic knowledge of Java: String. Needless to say the importance of the String class, it can be said to be the most used class in our back-end development, so it is necessary to talk about it.

Detailed explanation of the method of converting int type to bytes in PHP Detailed explanation of the method of converting int type to bytes in PHP Mar 06, 2024 pm 06:18 PM

Detailed explanation of the method of converting int type to byte in PHP In PHP, we often need to convert the integer type (int) to the byte (Byte) type, such as when dealing with network data transmission, file processing, or encryption algorithms. This article will introduce in detail how to convert the int type to the byte type and provide specific code examples. 1. The relationship between int type and byte In the computer field, the basic data type int represents an integer, while byte (Byte) is a computer storage unit, usually 8-bit binary data

Go language development essentials: 5 popular framework recommendations Go language development essentials: 5 popular framework recommendations Mar 24, 2024 pm 01:15 PM

"Go Language Development Essentials: 5 Popular Framework Recommendations" As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast

C++ program to convert double type variable to int type C++ program to convert double type variable to int type Aug 25, 2023 pm 08:25 PM

In C++, variables of type int can only hold positive or negative integer values; they cannot hold decimal values. There are float and double values ​​available for this purpose. The double data type was created to store decimals up to seven digits after the decimal point. Conversion of an integer to a double data type can be done automatically by the compiler (called an "implicit" conversion), or it can be explicitly requested by the programmer from the compiler (called an "explicit" conversion). In the following sections, we'll cover various conversion methods. Implicit conversions The compiler performs implicit type conversions automatically. To achieve this, two variables are required - one of floating point type and the other of integer type. When we simply assign a floating point value or variable to an integer variable, the compiler takes care of all the other things

See all articles