当前位置:网站首页>mb_ substr()、mb_ Strpos() function (story)

mb_ substr()、mb_ Strpos() function (story)

2022-04-23 01:39:00 Savanna07

In today's buu Did one web The subject of , stay php The audit saw mb_substr()、mb_strpos() I don't know much about functions , I checked the first-hand information on the Internet to understand , Close up here to record

I don't say much nonsense , Go straight to the point

mb_substr() function

Before we know this function , We need to know its little brother first substr() function

its substr() The function is a function that returns part of a string , First explain what this little brother looks like

substr(string,start,length) / / If star The argument is negative and length Less than or equal to start, be length by 0

In this way, there may be a little partner or I don't know this little brother very well , Then after reading this story, you will be able to have a great understanding of this

Aside : The younger brother substr() And big brother md_substr() The two brothers set up a company together , No, it's just the opening of their two companies today

The younger brother : Hello everyone , My name is substr(), I am a function specially used to output part of the string you pass in , My big brother has the same function as me , But ah, it can be used in many languages , But I only use it in English . Let's hear if my big brother is awesome

eldest brother : Stop talking nonsense , Let's get into talent

Aside : Just after opening, a party a came to cooperate with them

Party a father : My project is very simple , Just do what I want  [substr("hello world",6)] This is the plan

eldest brother : I'll leave such a small project to you

The younger brother : Come on, brother , Good guy, I'm busy again , A meal operation output “world”

Party a father : I feel this world Not very good , Can you change this [substr("hello world",6,4)] try

The younger brother : Party A's father is not satisfied , Elder brother, have I failed too much

eldest brother : It's not normal for Party A to ask for more , Keep doing it

The younger brother : The eldest brother spoke. I have to do this , I have another good meal , Suddenly output again “wor”

Party a father : What is this? This is , It's so ugly , The original one is better , Take that. 4 Switch to 5 got

The younger brother : Come on, let's go , I don't want to rush out again “worl”

Party a father : good heavens , I don't want to output 5 Well, here , What's going on? What's going on 4 One !! Isn't it unprofessional? You

eldest brother : Don't be angry, father , I'm a newcomer and I'm not sensible , But here we are php Language is closed on the left and open on the right , It can only get the previous one of the specified number , It's not easy for us to break this old rule, right

The younger brother :5555 eldest brother 5555

Party a father : All right, all right. , Then put this, that 5 Change to 6 Output it to me and finish it

eldest brother : Don't worry, you must be OK this time

[substr("hello world",6,6)] Successfully output again “world”

Party a father : It can be done well , I have a friend here who also has a project [$str=' It's today Monday'] I need to find you , He wants to export “ yes Monday”

The younger brother : Oh, brother, this is a big project , I can't do this

eldest brother : Be careful. I'll take over this big project myself

eldest brother :[md_substr(" It's today Monday",2)] Party A's father, look at this. Are you satisfied

Party a father : It's worthy of being a big brother , One shot is extraordinary ! This cooperation is very pleasant

eldest brother 、 The younger brother : looking forward to your next visit !

mb_strpos() function

That day, a recruiter came to the two brothers' company , Claiming to be a distant relative of big brother mb_strpos() function

eldest brother : Good guy, let me see which distant relative of mine

see mb_strpos() Just stepped into the door of the company , Big brother immediately hugged him

eldest brother : Cousin, I haven't seen you for a long time , You have changed so much that you can hardly recognize it

The younger brother : eldest brother , This is really your distant relative

elder male cousin : I heard you started a company in a big city , I'll come to you right away

eldest brother : Ouch, cousin , What skills did you bring to the interview today

The younger brother : Our company won't keep idle people

elder male cousin : Now I've brought my housekeeping skills , Rest assured

The younger brother : Well, show us your housekeeping skills

elder male cousin : I have golden eyes , Very sensitive to find , If you want to know the position of that character, I can tell you immediately , And I don't know any language , English or Chinese is OK !

The younger brother : Hey, I don't believe it

eldest brother : Let's have one on the spot ?!$str‘jintianyoudianxihuanni’, Please tell me y and n The location of

elder male cousin :7!!!!2!!!1

eldest brother : Yes, cousin , This skill is good ! Congratulations on your admission, cousin

The younger brother : No, big brother , that n There are so many positions , It only said one

elder male cousin : You don't know something about this man , Although our eyes are sharp , But we can only use this function once for each character , So we can only find the first one

eldest brother : Ouch! , This admission is too fast ( Remorse )

This is the end of the story. I wonder if you understand these two functions ~

There will be another issue !!!

版权声明
本文为[Savanna07]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230136106026.html