SlideShare a Scribd company logo
Created by Nikul Shah
STRING FUNCTIONS
NIKUL SHAH 1
STRLEN()
• <?php
• echo strlen("Hello Nikul!");
• ?>
• /*output */
• 12
NIKUL SHAH 2
STR_WORD_COUNT()
• <?php
• echo str_word_count("Some people tend to forget that kindness and manners are free.");
• ?>
NIKUL SHAH 3
STRREV()
• <?php
• echo strrev("don't loss your hope.");
• ?>
NIKUL SHAH 4
STRPOS()
• strpos() function searches for a specific text within a string.
• If a match is found, the function returns the character position of the first match. If no
match is found, it will return FALSE.
• <?php
• echo strpos("Destiny works.", "works");
• ?>
NIKUL SHAH 5
STR_REPLACE ------ STRTR
• $search = array('A', 'B', 'C', 'D', 'E');
• $replace = array('B', 'C', 'D', 'E', 'F');
• $subject = 'A';
• $trans = array('A' => 'B','B'=>'C','C'=>'D','D'=>'E','E'=>'F');
• echo str_replace($search, $replace, $subject);
• echo "<br/>";
• echo strtr($subject,$trans);
NIKUL SHAH 6
• <?php
• echo str_replace("Nikul","Shah","Nik shah");
• ?>
NIKUL SHAH 7
ADDSLASHES()
• <?php
• $str=addslashes("today is 'monday'");
• echo "$str";
• ?>
• //output
• today is 'monday'
NIKUL SHAH 8
ADDCSLASHES()
• <?php
• $str=addcslashes("Nikul","k");
• echo "$str";
• ?>
• Be careful using addcslashes() on 0 (NULL), r (carriage return), n (newline), f (form feed),
t (tab) and v (vertical tab). In PHP, 0, r, n, t, f and v are predefined escape sequences.
NIKUL SHAH 9
CHR()
• The chr() function returns a character from the specified ASCII value.
• The ASCII value can be specified in decimal, octal, or hex values. Octal values are
defined by a leading 0, while hex values are defined by a leading 0x.
• <?php
$str = chr(43);
$str2 = chr(61);
echo("2 $str 2 $str2 4");
?>
NIKUL SHAH 10
EXPLODE()
• The explode() function breaks a string into an array.
• Note: The "separator" parameter cannot be an empty string.
• <?php
• $str="Hello my name is 'Nikul'";
• print_r (explode(" ",$str));
• print_r(explode(',',$str,0));
• ?>
• Using limits parameter it will returns no of elements.
• This function can not run on echo.
NIKUL SHAH 11
IMPLODE()
• implode() function returns a string from the elements of an array
• <?php
• $str =array('Hello','Nikul','How','are','You?');
• print_r(implode(",",$str));
• ?>.
NIKUL SHAH 12
JOIN()
• Joins array into string. Same as implode()
• <?php
• $im=array("nikul","Shah");
• echo (join(" ",$im));
• ?>
NIKUL SHAH 13
MD5()
• This function Calculates the MD5 hash of a string.
• <?php
• $im=array("nikul","Shah");
• echo md5(join(" ",$im));
• ?>
• 4994812ba7d125a30e2b9c04e7b7c014
NIKUL SHAH 14
NL2BR()
• Inserts HTML line breaks in front of each newline in a string
• <?php
• $n="Nikul nShah";
• echo nl2br($n);
• ?>
NIKUL SHAH 15
STR_SPLIT()
• This funciton splits string into an array.
• <?php
• $n="Nikul Shah";
• print_r(str_split($n));
?>
Array ( [0] => N [1] => i [2] => k [3] => u [4] => l [5] => [6] => S [7] => h [8] => a [9] => h )
NIKUL SHAH 16
STRCMP()
• The strcmp() function compares two strings.
• <?php
• echo strcmp("Nikul","Nik");
• ?>
• 2
NIKUL SHAH 17
STRTOLOWER()
• Converts string from uppercase to lower case.
• <?php
• echo strtolower("Nikul Shah");
• ?>
NIKUL SHAH 18
STRTOUPPER()
• Converts string from lowercase to upper case.
• <?php
• echo strtoupper("Nikul Shah");
• ?>
NIKUL SHAH 19
TRIM()
• This function removes the while space.
• <?php
• $str = "Nikul Shah!";
• echo $str . "<br>";
• echo trim($str,"Nik");
• ?>
• Nikul Shah!
ul Shah!
NIKUL SHAH 20
NUMBER_FORMAT()
• This function formats a number with grouped.
• <?php
• echo number_format("100000",1);
• ?>
• 100,000.0
NIKUL SHAH 21
RTIRM()
• Removes white space or other char. From right hand side of the string.
• <?php
• $str = "Nikul Shah!";
• echo $str . "<br>";
• echo rtrim($str,"l Sah!");
• ?>
• Nikul Shah!
Niku
NIKUL SHAH 22
STR_IREPLACE()
• Replaces some char of the string.
• <?php
• echo str_ireplace("Nikul", "hi","hey hello");
• ?>
• hey hello
NIKUL SHAH 23
STR_REPEAT()
• str_repeat() function repeats a string a specified number of times.
• <?php
• echo str_repeat("Nikul",10);
• ?>
• NikulNikulNikulNikulNikulNikulNikulNikulNikulNikul
NIKUL SHAH 24
STR_REPLACE()
• <?php
• $r=array("hello","hey", "Nikul","hello");
• print_r(str_replace("hello","hi",$r,$i));
• echo"<br>";
• echo "replacements are :$i";
• ?>
• Array ( [0] => hi [1] => hey [2] => Nikul [3] => hi )
replacements are :2
NIKUL SHAH 25
STR_SHUFFLE()
• <?php
• echo str_shuffle("Nikul");
• ?>
• ikuNl
NIKUL SHAH 26
STR_WORD_COUNT()
• Counts the word in the string.
• <?php
• echo str_word_count("Nikul Shah");
• ?>
• 2
NIKUL SHAH 27
STRCASECMP()
<?php
• echo strcasecmp("Nikul","Nikul");
• ?>
• 0 If this function returns 0, the two strings are equal.
• 0 - if the two strings are equal
• <0 - if string1 is less than string2
• >0 - if string1 is greater than string2
NIKUL SHAH 28
STR_PAD()
• <?php
• $str = "Hello Nikul";
• echo str_pad($str,40,".");
• ?>
• Hello Nikul.............................
NIKUL SHAH 29
STRCSPN()
• Retruns the no of char found in a string before any part of some specified char are found.
• <?php
• $str = "Hello Nikul";
• echo strcspn($str,"N");
• ?>
• 6
NIKUL SHAH 30
STRCHR()
• Finds the first occurrence of a string inside another string . Alias strstr().
• This is case sensitive.
• <?php
• $str = "Hello Nikul";
• echo strchr($str,“Nikul");
• ?>
NIKUL SHAH 31
STRISTR()
• Finds the first occurrence of a string inside another string . Alias strstr().
• This is case insensitive.
• $str = "Hello Nikul";
• echo strchr($str,“nikul");
• ?>
NIKUL SHAH 32
STRIPOS()
• stripos() function finds the position of the first occurrence of a string inside another string.
• <?php
• echo stripos("today is Sunday","Sunday");
• ?>
NIKUL SHAH 33
STRSPN()
• Returns the number of characters found in a string that contains only characters from a
specified charlist
• <?php
• echo strspn("Nikul","ikul");
• ?>
• 0
NIKUL SHAH 34
CONVERT_UUENCODE()
• <?php
$str = "Hello Nikul!";
echo convert_uuencode($str);
?>
• convert_uudecode()
• $decodeString = convert_uudecode($encodeString);
echo $decodeString;
NIKUL SHAH 35
ENJOYED !!! ???
NEXT ARRAY.
BY NIKUL SHAH
NIKUL SHAH 36
Ad

More Related Content

What's hot (20)

Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
Simon Proctor
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
Simon Proctor
 
... now write an interpreter (PHPem 2016)
... now write an interpreter (PHPem 2016)... now write an interpreter (PHPem 2016)
... now write an interpreter (PHPem 2016)
James Titcumb
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
Eugene Zharkov
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to Elixir
Paweł Dawczak
 
Optimizing Queries with Explain
Optimizing Queries with ExplainOptimizing Queries with Explain
Optimizing Queries with Explain
MYXPLAIN
 
Fact, Fiction, and FP
Fact, Fiction, and FPFact, Fiction, and FP
Fact, Fiction, and FP
Brian Lonsdorf
 
Ricky Bobby's World
Ricky Bobby's WorldRicky Bobby's World
Ricky Bobby's World
Brian Lonsdorf
 
Explain
ExplainExplain
Explain
Ligaya Turmelle
 
Cycle.js: Functional and Reactive
Cycle.js: Functional and ReactiveCycle.js: Functional and Reactive
Cycle.js: Functional and Reactive
Eugene Zharkov
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful wedding
Stéphane Wirtel
 
Indexing thousands of writes per second with redis
Indexing thousands of writes per second with redisIndexing thousands of writes per second with redis
Indexing thousands of writes per second with redis
pauldix
 
Java Cheat Sheet
Java Cheat SheetJava Cheat Sheet
Java Cheat Sheet
Saeid Zebardast
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
ECMAScript 6 new features
ECMAScript 6 new featuresECMAScript 6 new features
ECMAScript 6 new features
GephenSG
 
Into Clojure
Into ClojureInto Clojure
Into Clojure
Alf Kristian Støyle
 
56 Query Optimization
56 Query Optimization56 Query Optimization
56 Query Optimization
MYXPLAIN
 
C# 7
C# 7C# 7
C# 7
Mike Harris
 
Efficient Use of indexes in MySQL
Efficient Use of indexes in MySQLEfficient Use of indexes in MySQL
Efficient Use of indexes in MySQL
Aleksandr Kuzminsky
 
ECMAScript 6 and beyond
ECMAScript 6 and beyondECMAScript 6 and beyond
ECMAScript 6 and beyond
Francis Johny
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
Simon Proctor
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
Simon Proctor
 
... now write an interpreter (PHPem 2016)
... now write an interpreter (PHPem 2016)... now write an interpreter (PHPem 2016)
... now write an interpreter (PHPem 2016)
James Titcumb
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to Elixir
Paweł Dawczak
 
Optimizing Queries with Explain
Optimizing Queries with ExplainOptimizing Queries with Explain
Optimizing Queries with Explain
MYXPLAIN
 
Cycle.js: Functional and Reactive
Cycle.js: Functional and ReactiveCycle.js: Functional and Reactive
Cycle.js: Functional and Reactive
Eugene Zharkov
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful wedding
Stéphane Wirtel
 
Indexing thousands of writes per second with redis
Indexing thousands of writes per second with redisIndexing thousands of writes per second with redis
Indexing thousands of writes per second with redis
pauldix
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
ECMAScript 6 new features
ECMAScript 6 new featuresECMAScript 6 new features
ECMAScript 6 new features
GephenSG
 
56 Query Optimization
56 Query Optimization56 Query Optimization
56 Query Optimization
MYXPLAIN
 
Efficient Use of indexes in MySQL
Efficient Use of indexes in MySQLEfficient Use of indexes in MySQL
Efficient Use of indexes in MySQL
Aleksandr Kuzminsky
 
ECMAScript 6 and beyond
ECMAScript 6 and beyondECMAScript 6 and beyond
ECMAScript 6 and beyond
Francis Johny
 

Viewers also liked (7)

strings
stringsstrings
strings
teach4uin
 
Implementation Of String Functions In C
Implementation Of String Functions In CImplementation Of String Functions In C
Implementation Of String Functions In C
Fazila Sadia
 
String function
String functionString function
String function
Jignesh Patel
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functions
mohamed sikander
 
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
String in c
String in cString in c
String in c
Suneel Dogra
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
DevoAjit Gupta
 
Implementation Of String Functions In C
Implementation Of String Functions In CImplementation Of String Functions In C
Implementation Of String Functions In C
Fazila Sadia
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functions
mohamed sikander
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
DevoAjit Gupta
 
Ad

Similar to String functions (20)

UNIT II (7).pptx
UNIT II (7).pptxUNIT II (7).pptx
UNIT II (7).pptx
DrDhivyaaCRAssistant
 
UNIT II (7).pptx
UNIT II (7).pptxUNIT II (7).pptx
UNIT II (7).pptx
DrDhivyaaCRAssistant
 
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeString handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
php string part 3
php string part 3php string part 3
php string part 3
monikadeshmane
 
Tokens in php (php: Hypertext Preprocessor).pptx
Tokens in  php (php: Hypertext Preprocessor).pptxTokens in  php (php: Hypertext Preprocessor).pptx
Tokens in php (php: Hypertext Preprocessor).pptx
BINJAD1
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
Muthuselvam RS
 
strings in php how to use different data types in string
strings in php how to use different data types in stringstrings in php how to use different data types in string
strings in php how to use different data types in string
vishal choudhary
 
PHP string-part 1
PHP string-part 1PHP string-part 1
PHP string-part 1
monikadeshmane
 
php_string.pdf
php_string.pdfphp_string.pdf
php_string.pdf
Sharon Manmothe
 
String variable in php
String variable in phpString variable in php
String variable in php
chantholnet
 
Intoduction to php strings
Intoduction to php  stringsIntoduction to php  strings
Intoduction to php strings
baabtra.com - No. 1 supplier of quality freshers
 
lab4_php
lab4_phplab4_php
lab4_php
tutorialsruby
 
lab4_php
lab4_phplab4_php
lab4_php
tutorialsruby
 
Php string function
Php string function Php string function
Php string function
Ravi Bhadauria
 
Array String - Web Programming
Array String - Web ProgrammingArray String - Web Programming
Array String - Web Programming
Amirul Azhar
 
PHP Strings and Patterns
PHP Strings and PatternsPHP Strings and Patterns
PHP Strings and Patterns
Henry Osborne
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
Ahmed Swilam
 
Php functions
Php functionsPhp functions
Php functions
JIGAR MAKHIJA
 
PHP and MySQL with snapshots
 PHP and MySQL with snapshots PHP and MySQL with snapshots
PHP and MySQL with snapshots
richambra
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3
Mohd Harris Ahmad Jaal
 
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeString handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 
Tokens in php (php: Hypertext Preprocessor).pptx
Tokens in  php (php: Hypertext Preprocessor).pptxTokens in  php (php: Hypertext Preprocessor).pptx
Tokens in php (php: Hypertext Preprocessor).pptx
BINJAD1
 
strings in php how to use different data types in string
strings in php how to use different data types in stringstrings in php how to use different data types in string
strings in php how to use different data types in string
vishal choudhary
 
String variable in php
String variable in phpString variable in php
String variable in php
chantholnet
 
Array String - Web Programming
Array String - Web ProgrammingArray String - Web Programming
Array String - Web Programming
Amirul Azhar
 
PHP Strings and Patterns
PHP Strings and PatternsPHP Strings and Patterns
PHP Strings and Patterns
Henry Osborne
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
Ahmed Swilam
 
PHP and MySQL with snapshots
 PHP and MySQL with snapshots PHP and MySQL with snapshots
PHP and MySQL with snapshots
richambra
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3
Mohd Harris Ahmad Jaal
 
Ad

Recently uploaded (20)

YSPH VMOC Special Report - Measles Outbreak Southwest US 5-17-2025 .pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-17-2025  .pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-17-2025  .pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-17-2025 .pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
Quiz Club of PSG College of Arts & Science
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
The History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.pptThe History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.ppt
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
ITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQ
SONU HEETSON
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic SuccessAerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
online college homework help
 
How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
ITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQ
SONU HEETSON
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic SuccessAerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
online college homework help
 
How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
MICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdfMICROBIAL GENETICS -tranformation and tranduction.pdf
MICROBIAL GENETICS -tranformation and tranduction.pdf
DHARMENDRA SAHU
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 

String functions

  • 1. Created by Nikul Shah STRING FUNCTIONS NIKUL SHAH 1
  • 2. STRLEN() • <?php • echo strlen("Hello Nikul!"); • ?> • /*output */ • 12 NIKUL SHAH 2
  • 3. STR_WORD_COUNT() • <?php • echo str_word_count("Some people tend to forget that kindness and manners are free."); • ?> NIKUL SHAH 3
  • 4. STRREV() • <?php • echo strrev("don't loss your hope."); • ?> NIKUL SHAH 4
  • 5. STRPOS() • strpos() function searches for a specific text within a string. • If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE. • <?php • echo strpos("Destiny works.", "works"); • ?> NIKUL SHAH 5
  • 6. STR_REPLACE ------ STRTR • $search = array('A', 'B', 'C', 'D', 'E'); • $replace = array('B', 'C', 'D', 'E', 'F'); • $subject = 'A'; • $trans = array('A' => 'B','B'=>'C','C'=>'D','D'=>'E','E'=>'F'); • echo str_replace($search, $replace, $subject); • echo "<br/>"; • echo strtr($subject,$trans); NIKUL SHAH 6
  • 7. • <?php • echo str_replace("Nikul","Shah","Nik shah"); • ?> NIKUL SHAH 7
  • 8. ADDSLASHES() • <?php • $str=addslashes("today is 'monday'"); • echo "$str"; • ?> • //output • today is 'monday' NIKUL SHAH 8
  • 9. ADDCSLASHES() • <?php • $str=addcslashes("Nikul","k"); • echo "$str"; • ?> • Be careful using addcslashes() on 0 (NULL), r (carriage return), n (newline), f (form feed), t (tab) and v (vertical tab). In PHP, 0, r, n, t, f and v are predefined escape sequences. NIKUL SHAH 9
  • 10. CHR() • The chr() function returns a character from the specified ASCII value. • The ASCII value can be specified in decimal, octal, or hex values. Octal values are defined by a leading 0, while hex values are defined by a leading 0x. • <?php $str = chr(43); $str2 = chr(61); echo("2 $str 2 $str2 4"); ?> NIKUL SHAH 10
  • 11. EXPLODE() • The explode() function breaks a string into an array. • Note: The "separator" parameter cannot be an empty string. • <?php • $str="Hello my name is 'Nikul'"; • print_r (explode(" ",$str)); • print_r(explode(',',$str,0)); • ?> • Using limits parameter it will returns no of elements. • This function can not run on echo. NIKUL SHAH 11
  • 12. IMPLODE() • implode() function returns a string from the elements of an array • <?php • $str =array('Hello','Nikul','How','are','You?'); • print_r(implode(",",$str)); • ?>. NIKUL SHAH 12
  • 13. JOIN() • Joins array into string. Same as implode() • <?php • $im=array("nikul","Shah"); • echo (join(" ",$im)); • ?> NIKUL SHAH 13
  • 14. MD5() • This function Calculates the MD5 hash of a string. • <?php • $im=array("nikul","Shah"); • echo md5(join(" ",$im)); • ?> • 4994812ba7d125a30e2b9c04e7b7c014 NIKUL SHAH 14
  • 15. NL2BR() • Inserts HTML line breaks in front of each newline in a string • <?php • $n="Nikul nShah"; • echo nl2br($n); • ?> NIKUL SHAH 15
  • 16. STR_SPLIT() • This funciton splits string into an array. • <?php • $n="Nikul Shah"; • print_r(str_split($n)); ?> Array ( [0] => N [1] => i [2] => k [3] => u [4] => l [5] => [6] => S [7] => h [8] => a [9] => h ) NIKUL SHAH 16
  • 17. STRCMP() • The strcmp() function compares two strings. • <?php • echo strcmp("Nikul","Nik"); • ?> • 2 NIKUL SHAH 17
  • 18. STRTOLOWER() • Converts string from uppercase to lower case. • <?php • echo strtolower("Nikul Shah"); • ?> NIKUL SHAH 18
  • 19. STRTOUPPER() • Converts string from lowercase to upper case. • <?php • echo strtoupper("Nikul Shah"); • ?> NIKUL SHAH 19
  • 20. TRIM() • This function removes the while space. • <?php • $str = "Nikul Shah!"; • echo $str . "<br>"; • echo trim($str,"Nik"); • ?> • Nikul Shah! ul Shah! NIKUL SHAH 20
  • 21. NUMBER_FORMAT() • This function formats a number with grouped. • <?php • echo number_format("100000",1); • ?> • 100,000.0 NIKUL SHAH 21
  • 22. RTIRM() • Removes white space or other char. From right hand side of the string. • <?php • $str = "Nikul Shah!"; • echo $str . "<br>"; • echo rtrim($str,"l Sah!"); • ?> • Nikul Shah! Niku NIKUL SHAH 22
  • 23. STR_IREPLACE() • Replaces some char of the string. • <?php • echo str_ireplace("Nikul", "hi","hey hello"); • ?> • hey hello NIKUL SHAH 23
  • 24. STR_REPEAT() • str_repeat() function repeats a string a specified number of times. • <?php • echo str_repeat("Nikul",10); • ?> • NikulNikulNikulNikulNikulNikulNikulNikulNikulNikul NIKUL SHAH 24
  • 25. STR_REPLACE() • <?php • $r=array("hello","hey", "Nikul","hello"); • print_r(str_replace("hello","hi",$r,$i)); • echo"<br>"; • echo "replacements are :$i"; • ?> • Array ( [0] => hi [1] => hey [2] => Nikul [3] => hi ) replacements are :2 NIKUL SHAH 25
  • 26. STR_SHUFFLE() • <?php • echo str_shuffle("Nikul"); • ?> • ikuNl NIKUL SHAH 26
  • 27. STR_WORD_COUNT() • Counts the word in the string. • <?php • echo str_word_count("Nikul Shah"); • ?> • 2 NIKUL SHAH 27
  • 28. STRCASECMP() <?php • echo strcasecmp("Nikul","Nikul"); • ?> • 0 If this function returns 0, the two strings are equal. • 0 - if the two strings are equal • <0 - if string1 is less than string2 • >0 - if string1 is greater than string2 NIKUL SHAH 28
  • 29. STR_PAD() • <?php • $str = "Hello Nikul"; • echo str_pad($str,40,"."); • ?> • Hello Nikul............................. NIKUL SHAH 29
  • 30. STRCSPN() • Retruns the no of char found in a string before any part of some specified char are found. • <?php • $str = "Hello Nikul"; • echo strcspn($str,"N"); • ?> • 6 NIKUL SHAH 30
  • 31. STRCHR() • Finds the first occurrence of a string inside another string . Alias strstr(). • This is case sensitive. • <?php • $str = "Hello Nikul"; • echo strchr($str,“Nikul"); • ?> NIKUL SHAH 31
  • 32. STRISTR() • Finds the first occurrence of a string inside another string . Alias strstr(). • This is case insensitive. • $str = "Hello Nikul"; • echo strchr($str,“nikul"); • ?> NIKUL SHAH 32
  • 33. STRIPOS() • stripos() function finds the position of the first occurrence of a string inside another string. • <?php • echo stripos("today is Sunday","Sunday"); • ?> NIKUL SHAH 33
  • 34. STRSPN() • Returns the number of characters found in a string that contains only characters from a specified charlist • <?php • echo strspn("Nikul","ikul"); • ?> • 0 NIKUL SHAH 34
  • 35. CONVERT_UUENCODE() • <?php $str = "Hello Nikul!"; echo convert_uuencode($str); ?> • convert_uudecode() • $decodeString = convert_uudecode($encodeString); echo $decodeString; NIKUL SHAH 35
  • 36. ENJOYED !!! ??? NEXT ARRAY. BY NIKUL SHAH NIKUL SHAH 36
  翻译: