SlideShare a Scribd company logo
PHP -  Introduction to  String Handling
Introduction toIntroduction to
STRINGSTRING
HandlingHandling
StringStringlerler
$a = trim($name); //kırpma
$a = nl2br(“line1nline2”); // “line1 br line2”< > çevirir
printf(“total %d”, 15); // prints to stdout
Strings in PHPStrings in PHP
A string is an array of character.
$a = strtoupper($name); // büyük harf
$a = strtolower($name); // küçük harf
$a = ucfirst($name); // İlk karakterbüyük
$text = "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "n", 1);
$a = crpyt($a); // şifreleme
$a = decrypt(encrpyt($a)); // 2-way encription
with Mcrpt extension
Strings in PHPStrings in PHP
Slash ekler- (veritabanına eklerken)
$a = AddSlashes($typedText);
Slashları kaldırır
$a = StripSlashes($typedText);
StringString birleştirme vebirleştirme ve
ayırmaayırma
?<
$pizza = "piece1 piece2 piece3 piece4 piece5";
$pieces = explode (" ", $pizza); // split string into pieces
for($i=0; $i count($pieces); $i++)<
echo "- $pieces[$i] br ";> < >
echo implode(“:", $pieces); // join strings using “:“
?>
Stringleri ayırmaStringleri ayırma
$string = "This is an example string";
$tok = strtok ($string," ");
while ($tok) {
echo "Word=$tok<br>";
$tok = strtok (" ");
}
Strings in PHPStrings in PHP
• string substr (string string, int start [, int length])
• int strlen (string str)
• int strcmp (string str1, string str2) Returns
o < 0 if str1 is less than str2;
o > 0 if str1 is greater than str2,
o 0 if they are equal.
Regular ExpressionsRegular Expressions
• A way of describing a pattern in string
• Use special characters to indicate meta-meaning in
addition to exact matching.
• More powerful than exact matching
• There are 2 sets of function on regular expressions in
PHP
o Functions using POSIX-type reg expr
o Functions using Perl-type reg expr
Regular ExpressionsRegular Expressions
“.” tek bir karakterle eşleşir
.at == “cat”, “sat”, etc.
[a-zA-Z0-9] tek bir karakterle (a-zA-Z0-9)
arasında eşleşir.
[^0-9] rakam olmayan birşeyle eşleşir.
Regular Expr: Built-inRegular Expr: Built-in
Char-setsChar-sets
• [[:alphanum:]] --harf
• [[:digit:]] rakamla
• [[:space:]] boşlukla
Regular ExprRegular Expr
• . Tek karakter
• + 1 ya da daha fazla bulunan stringle
• * 0 ya da daha fazla bulunan stringle
• [a-z] karakter
• ^ değil anlamında
• $ string sonu
• | or
•  özel karakterleri atlar
• (sub-expr) -- sub-expression
• (sub-expr){i,j} i min i, max j ile sub-expr olma durumu
Reg Expr Functions (Perl)Reg Expr Functions (Perl)
• preg_match — Perform a reg expr match
• preg_match_all — Perform a global r.e. match
• preg_replace — Perform a re search & replace
• preg_split — Split string by a reg expr
preg_match -- Perform apreg_match -- Perform a
re matchre match
int preg_match (string pattern, string subject [, array
matches])
• Searches subject for a match to the reg expr given
in pattern.
• Return one match for each subpattern () only
• $matches[0]: the text matching the full pattern
• $matches[1]: the text that matched the first
captured parenthesized subpattern, and so on.
• Returns true if a match for pattern was found
preg_match -- Perform apreg_match -- Perform a
re matchre match
preg_match("/pattern/modifier", subject, array)
Modifiers:
• i: case insensitive search
• m: by default subject is treated single-line even if it contains
newlines, m makes PCRE treat subject multiline (for ^, $)
• s: makes . metacharacter match n
• x: whitespace in pattern is ignored
• E: $ matches only at the end of subject
• U: behave ungreedy (comert)
preg_match -- Perform apreg_match -- Perform a
re matchre match$s = <<<STR
<table><tr><td>cell1</td><td>cell2</td></tr>
<tr><td>cell3</td><td>cell4</td></tr></table>
STR;
preg_match("/<table>(.*)</table>/Us", $s, $r)
// anything between <table> and </table>
preg_match("/<tr><td>(.*)</td><td>(.*)</td></tr>/Us", $r[1],
$t)
// matches cell1 and cell2
preg_match("/<tr>(.*)</tr>/Us", $r[1], $t);
// matches <td>cell1</td><td>cell2</td>
preg_matchpreg_match_all:_all: Perform Perform globalglobal matchmatch
int preg_match_all (string pattern, string subject, array
matches [, int order])
• Searches subject for all matches and puts them in
matches in the order specified by order.
• After the first match, the subsequent ones are
continued on from end of the last match.
• $matches[0] is an array of full pattern matches
• $matches[1] is an array of strings matched by the
first parenthesized subpattern, and so on.
preg_matchpreg_match_all:_all: Perform Perform globalglobal matchmatch
preg_match("/<table>(.*)</table>/Us", $s, $r);
preg_match_all("/<tr><td>(.*)</td><td>(.*)</td></
tr>/Us", $r[1], $t);
echo $t[1][0],$t[1][1],$t[2][0],$t[2][1];
// prints cell1cell3cell2cell4
preg_match_all("/<tr><td>(.*)</td><td>(.*)</td></
tr>/Us", $r[1], $t, PREG_SET_ORDER );
//Orders results so that $matches[0] is an array of first
set of matches, $matches[1] is an array of second
set of matches,…
echo $t[0][1],$t[0][2],$t[1][1],$t[1][2];
// returns cell1cell2cell3cell4
preg_matchpreg_match_all:_all: Perform Perform globalglobal matchmatch
Back reference
preg_match_all ("/(<([w]+)[^>]*>)(.*)(</2>)/",
$html, $matches);
// 2 means [w]+
preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", $html, $m)
// return text in html tags
Convert HTML to TextConvert HTML to Text
$html = file(“http://www.page.com”);
$search = array ("'<script[^>]*?>.*?</script>'si",
"'<[/!]*?[^<>]*?>'si",
"'([rn])[s]+'",
"'&(quote|#34);'i",
"'&(amp|#38);'i", …);
$replace = array ("", "", "1", """, "&", …);
$text = preg_replace ($search, $replace, $html);
Reg Expr FunctionsReg Expr Functions
(POSIX)(POSIX)
• ereg (string pattern, string string [, array regs])
o Searches a string for matches to the regular expression given in pattern.
• ereg_replace (string pattern, string subs, string string)
o Scans string for matches to pattern, then replaces the matched text with
subs.
• array split (string pattern, string string [, int limit])
o Split string using pattern
Regular ExprRegular Expr
ereg ("abc", $string);
ereg ("^abc", $string);
ereg ("abc$", $string);
eregi ("(ozilla.[23]|MSIE.3)", $HTTP_USER_AGENT);
ereg ("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)",
$string,$regs);
$string = ereg_replace ("^", "<BR>", $string);
$string = ereg_replace ("$", "<BR>", $string);
$string = ereg_replace ("n", "", $string);
Regular ExprRegular Expr
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date,
$regs)) {
echo "$regs[3].$regs[2].$regs[1]";
}else{
echo "Invalid date format: $date";
}
Regular ExprRegular Expr
$string = "This is a test";
echo ereg_replace (" is", " was", $string);
echo ereg_replace ("( )is", "1was", $string);
echo ereg_replace ("(( )is)", "2was", $string);
Regular ExprRegular Expr
$date = "04/30/1973";
// Delimiters may be slash, dot, or hyphen list
($month, $day, $year) = split ('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year";
ThankThank You !!!You !!!
For More Information click below link:
Follow Us on:
http://vibranttechnologies.co.in/php-classes-in-
mumbai.html
Ad

More Related Content

What's hot (20)

Hashes
HashesHashes
Hashes
Krasimir Berov (Красимир Беров)
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel Computing
Andrew Shitov
 
Switching from java to groovy
Switching from java to groovySwitching from java to groovy
Switching from java to groovy
Paul Woods
 
Python Workshop
Python  Workshop Python  Workshop
Python Workshop
Assem CHELLI
 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
mussawir20
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
Andrew Shitov
 
Ruby cheat sheet
Ruby cheat sheetRuby cheat sheet
Ruby cheat sheet
Tharcius Silva
 
Php Basics Iterations, looping
Php Basics Iterations, loopingPhp Basics Iterations, looping
Php Basics Iterations, looping
Muthuganesh S
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In Erlang
Sean Cribbs
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
RajKumar Rampelli
 
Five
FiveFive
Five
Łukasz Langa
 
Perl6 one-liners
Perl6 one-linersPerl6 one-liners
Perl6 one-liners
Andrew Shitov
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
Andrew Shitov
 
php string part 3
php string part 3php string part 3
php string part 3
monikadeshmane
 
WordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressWordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPress
Alena Holligan
 
Practical approach to perl day2
Practical approach to perl day2Practical approach to perl day2
Practical approach to perl day2
Rakesh Mukundan
 
Lists and arrays
Lists and arraysLists and arrays
Lists and arrays
Krasimir Berov (Красимир Беров)
 
Bioinformatics p2-p3-perl-regexes v2014
Bioinformatics p2-p3-perl-regexes v2014Bioinformatics p2-p3-perl-regexes v2014
Bioinformatics p2-p3-perl-regexes v2014
Prof. Wim Van Criekinge
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
garux
 
Gigigo Ruby Workshop
Gigigo Ruby WorkshopGigigo Ruby Workshop
Gigigo Ruby Workshop
Alex Rupérez
 

Viewers also liked (15)

Php Using Arrays
Php Using ArraysPhp Using Arrays
Php Using Arrays
mussawir20
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
Dhani Ahmad
 
PHP
PHPPHP
PHP
sometech
 
PHP
PHPPHP
PHP
Steve Fort
 
PHP variables
PHP  variablesPHP  variables
PHP variables
Siddique Ibrahim
 
Php string function
Php string function Php string function
Php string function
Ravi Bhadauria
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
Computer Hardware & Trouble shooting
 
Php string
Php stringPhp string
Php string
argusacademy
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
Tiji Thomas
 
Cookie and session
Cookie and sessionCookie and session
Cookie and session
Aashish Ghale
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
Lena Petsenchuk
 
PHP slides
PHP slidesPHP slides
PHP slides
Farzad Wadia
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
Niit
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Jussi Pohjolainen
 
Ad

Similar to PHP - Introduction to String Handling (20)

Bioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introductionBioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introduction
Prof. Wim Van Criekinge
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
Muthuselvam RS
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
Dr.Ravi
 
Regular expressionfunction
Regular expressionfunctionRegular expressionfunction
Regular expressionfunction
ADARSH BHATT
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1
Dr.Ravi
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Raj Gupta
 
Regular Expressions in PHP, MySQL by programmerblog.net
Regular Expressions in PHP, MySQL by programmerblog.netRegular Expressions in PHP, MySQL by programmerblog.net
Regular Expressions in PHP, MySQL by programmerblog.net
Programmer Blog
 
Eag 201110-hrugregexpresentation-111006104128-phpapp02
Eag 201110-hrugregexpresentation-111006104128-phpapp02Eag 201110-hrugregexpresentation-111006104128-phpapp02
Eag 201110-hrugregexpresentation-111006104128-phpapp02
egoodwintx
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Andrea Telatin
 
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekingeBioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Prof. Wim Van Criekinge
 
Perl.predefined.variables
Perl.predefined.variablesPerl.predefined.variables
Perl.predefined.variables
King Hom
 
php string part 4
php string part 4php string part 4
php string part 4
monikadeshmane
 
Php Chapter 4 Training
Php Chapter 4 TrainingPhp Chapter 4 Training
Php Chapter 4 Training
Chris Chubb
 
Unit 1-array,lists and hashes
Unit 1-array,lists and hashesUnit 1-array,lists and hashes
Unit 1-array,lists and hashes
sana mateen
 
Basic regular expression, extended regular expression
Basic regular expression, extended regular expressionBasic regular expression, extended regular expression
Basic regular expression, extended regular expression
Dr. Girish GS
 
Php functions
Php functionsPhp functions
Php functions
JIGAR MAKHIJA
 
php_string.pdf
php_string.pdfphp_string.pdf
php_string.pdf
Sharon Manmothe
 
Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)
James Titcumb
 
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
James Titcumb
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
Jalpesh Vasa
 
Bioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introductionBioinformatica 06-10-2011-p2 introduction
Bioinformatica 06-10-2011-p2 introduction
Prof. Wim Van Criekinge
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
Dr.Ravi
 
Regular expressionfunction
Regular expressionfunctionRegular expressionfunction
Regular expressionfunction
ADARSH BHATT
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1
Dr.Ravi
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Raj Gupta
 
Regular Expressions in PHP, MySQL by programmerblog.net
Regular Expressions in PHP, MySQL by programmerblog.netRegular Expressions in PHP, MySQL by programmerblog.net
Regular Expressions in PHP, MySQL by programmerblog.net
Programmer Blog
 
Eag 201110-hrugregexpresentation-111006104128-phpapp02
Eag 201110-hrugregexpresentation-111006104128-phpapp02Eag 201110-hrugregexpresentation-111006104128-phpapp02
Eag 201110-hrugregexpresentation-111006104128-phpapp02
egoodwintx
 
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Bioinformatica: Esercizi su Perl, espressioni regolari e altre amenità (BMR G...
Andrea Telatin
 
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekingeBioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Prof. Wim Van Criekinge
 
Perl.predefined.variables
Perl.predefined.variablesPerl.predefined.variables
Perl.predefined.variables
King Hom
 
Php Chapter 4 Training
Php Chapter 4 TrainingPhp Chapter 4 Training
Php Chapter 4 Training
Chris Chubb
 
Unit 1-array,lists and hashes
Unit 1-array,lists and hashesUnit 1-array,lists and hashes
Unit 1-array,lists and hashes
sana mateen
 
Basic regular expression, extended regular expression
Basic regular expression, extended regular expressionBasic regular expression, extended regular expression
Basic regular expression, extended regular expression
Dr. Girish GS
 
Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)Climbing the Abstract Syntax Tree (IPC Fall 2017)
Climbing the Abstract Syntax Tree (IPC Fall 2017)
James Titcumb
 
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
James Titcumb
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
Jalpesh Vasa
 
Ad

More from Vibrant Technologies & Computers (20)

Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5
Vibrant Technologies & Computers
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
Vibrant Technologies & Computers
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
Vibrant Technologies & Computers
 
SQL- Introduction to SQL database
SQL- Introduction to SQL database SQL- Introduction to SQL database
SQL- Introduction to SQL database
Vibrant Technologies & Computers
 
ITIL - introduction to ITIL
ITIL - introduction to ITILITIL - introduction to ITIL
ITIL - introduction to ITIL
Vibrant Technologies & Computers
 
Salesforce - Introduction to Security & Access
Salesforce -  Introduction to Security & Access Salesforce -  Introduction to Security & Access
Salesforce - Introduction to Security & Access
Vibrant Technologies & Computers
 
Data ware housing- Introduction to olap .
Data ware housing- Introduction to  olap .Data ware housing- Introduction to  olap .
Data ware housing- Introduction to olap .
Vibrant Technologies & Computers
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.
Vibrant Technologies & Computers
 
Data ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingData ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housing
Vibrant Technologies & Computers
 
Salesforce - classification of cloud computing
Salesforce - classification of cloud computingSalesforce - classification of cloud computing
Salesforce - classification of cloud computing
Vibrant Technologies & Computers
 
Salesforce - cloud computing fundamental
Salesforce - cloud computing fundamentalSalesforce - cloud computing fundamental
Salesforce - cloud computing fundamental
Vibrant Technologies & Computers
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
Vibrant Technologies & Computers
 
SQL- Introduction to advanced sql concepts
SQL- Introduction to  advanced sql conceptsSQL- Introduction to  advanced sql concepts
SQL- Introduction to advanced sql concepts
Vibrant Technologies & Computers
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
Vibrant Technologies & Computers
 
SQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set OperationsSQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set Operations
Vibrant Technologies & Computers
 
Sas - Introduction to designing the data mart
Sas - Introduction to designing the data martSas - Introduction to designing the data mart
Sas - Introduction to designing the data mart
Vibrant Technologies & Computers
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
Vibrant Technologies & Computers
 
SAS - overview of SAS
SAS - overview of SASSAS - overview of SAS
SAS - overview of SAS
Vibrant Technologies & Computers
 
Teradata - Architecture of Teradata
Teradata - Architecture of TeradataTeradata - Architecture of Teradata
Teradata - Architecture of Teradata
Vibrant Technologies & Computers
 
Teradata - Restoring Data
Teradata - Restoring Data Teradata - Restoring Data
Teradata - Restoring Data
Vibrant Technologies & Computers
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.
Vibrant Technologies & Computers
 

Recently uploaded (20)

Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 

PHP - Introduction to String Handling

  • 3. StringStringlerler $a = trim($name); //kırpma $a = nl2br(“line1nline2”); // “line1 br line2”< > çevirir printf(“total %d”, 15); // prints to stdout
  • 4. Strings in PHPStrings in PHP A string is an array of character. $a = strtoupper($name); // büyük harf $a = strtolower($name); // küçük harf $a = ucfirst($name); // İlk karakterbüyük $text = "A very long woooooooooooord."; $newtext = wordwrap($text, 8, "n", 1); $a = crpyt($a); // şifreleme $a = decrypt(encrpyt($a)); // 2-way encription with Mcrpt extension
  • 5. Strings in PHPStrings in PHP Slash ekler- (veritabanına eklerken) $a = AddSlashes($typedText); Slashları kaldırır $a = StripSlashes($typedText);
  • 6. StringString birleştirme vebirleştirme ve ayırmaayırma ?< $pizza = "piece1 piece2 piece3 piece4 piece5"; $pieces = explode (" ", $pizza); // split string into pieces for($i=0; $i count($pieces); $i++)< echo "- $pieces[$i] br ";> < > echo implode(“:", $pieces); // join strings using “:“ ?>
  • 7. Stringleri ayırmaStringleri ayırma $string = "This is an example string"; $tok = strtok ($string," "); while ($tok) { echo "Word=$tok<br>"; $tok = strtok (" "); }
  • 8. Strings in PHPStrings in PHP • string substr (string string, int start [, int length]) • int strlen (string str) • int strcmp (string str1, string str2) Returns o < 0 if str1 is less than str2; o > 0 if str1 is greater than str2, o 0 if they are equal.
  • 9. Regular ExpressionsRegular Expressions • A way of describing a pattern in string • Use special characters to indicate meta-meaning in addition to exact matching. • More powerful than exact matching • There are 2 sets of function on regular expressions in PHP o Functions using POSIX-type reg expr o Functions using Perl-type reg expr
  • 10. Regular ExpressionsRegular Expressions “.” tek bir karakterle eşleşir .at == “cat”, “sat”, etc. [a-zA-Z0-9] tek bir karakterle (a-zA-Z0-9) arasında eşleşir. [^0-9] rakam olmayan birşeyle eşleşir.
  • 11. Regular Expr: Built-inRegular Expr: Built-in Char-setsChar-sets • [[:alphanum:]] --harf • [[:digit:]] rakamla • [[:space:]] boşlukla
  • 12. Regular ExprRegular Expr • . Tek karakter • + 1 ya da daha fazla bulunan stringle • * 0 ya da daha fazla bulunan stringle • [a-z] karakter • ^ değil anlamında • $ string sonu • | or • özel karakterleri atlar • (sub-expr) -- sub-expression • (sub-expr){i,j} i min i, max j ile sub-expr olma durumu
  • 13. Reg Expr Functions (Perl)Reg Expr Functions (Perl) • preg_match — Perform a reg expr match • preg_match_all — Perform a global r.e. match • preg_replace — Perform a re search & replace • preg_split — Split string by a reg expr
  • 14. preg_match -- Perform apreg_match -- Perform a re matchre match int preg_match (string pattern, string subject [, array matches]) • Searches subject for a match to the reg expr given in pattern. • Return one match for each subpattern () only • $matches[0]: the text matching the full pattern • $matches[1]: the text that matched the first captured parenthesized subpattern, and so on. • Returns true if a match for pattern was found
  • 15. preg_match -- Perform apreg_match -- Perform a re matchre match preg_match("/pattern/modifier", subject, array) Modifiers: • i: case insensitive search • m: by default subject is treated single-line even if it contains newlines, m makes PCRE treat subject multiline (for ^, $) • s: makes . metacharacter match n • x: whitespace in pattern is ignored • E: $ matches only at the end of subject • U: behave ungreedy (comert)
  • 16. preg_match -- Perform apreg_match -- Perform a re matchre match$s = <<<STR <table><tr><td>cell1</td><td>cell2</td></tr> <tr><td>cell3</td><td>cell4</td></tr></table> STR; preg_match("/<table>(.*)</table>/Us", $s, $r) // anything between <table> and </table> preg_match("/<tr><td>(.*)</td><td>(.*)</td></tr>/Us", $r[1], $t) // matches cell1 and cell2 preg_match("/<tr>(.*)</tr>/Us", $r[1], $t); // matches <td>cell1</td><td>cell2</td>
  • 17. preg_matchpreg_match_all:_all: Perform Perform globalglobal matchmatch int preg_match_all (string pattern, string subject, array matches [, int order]) • Searches subject for all matches and puts them in matches in the order specified by order. • After the first match, the subsequent ones are continued on from end of the last match. • $matches[0] is an array of full pattern matches • $matches[1] is an array of strings matched by the first parenthesized subpattern, and so on.
  • 18. preg_matchpreg_match_all:_all: Perform Perform globalglobal matchmatch preg_match("/<table>(.*)</table>/Us", $s, $r); preg_match_all("/<tr><td>(.*)</td><td>(.*)</td></ tr>/Us", $r[1], $t); echo $t[1][0],$t[1][1],$t[2][0],$t[2][1]; // prints cell1cell3cell2cell4 preg_match_all("/<tr><td>(.*)</td><td>(.*)</td></ tr>/Us", $r[1], $t, PREG_SET_ORDER ); //Orders results so that $matches[0] is an array of first set of matches, $matches[1] is an array of second set of matches,… echo $t[0][1],$t[0][2],$t[1][1],$t[1][2]; // returns cell1cell2cell3cell4
  • 19. preg_matchpreg_match_all:_all: Perform Perform globalglobal matchmatch Back reference preg_match_all ("/(<([w]+)[^>]*>)(.*)(</2>)/", $html, $matches); // 2 means [w]+ preg_match_all ("|<[^>]+>(.*)</[^>]+>|U", $html, $m) // return text in html tags
  • 20. Convert HTML to TextConvert HTML to Text $html = file(“http://www.page.com”); $search = array ("'<script[^>]*?>.*?</script>'si", "'<[/!]*?[^<>]*?>'si", "'([rn])[s]+'", "'&(quote|#34);'i", "'&(amp|#38);'i", …); $replace = array ("", "", "1", """, "&", …); $text = preg_replace ($search, $replace, $html);
  • 21. Reg Expr FunctionsReg Expr Functions (POSIX)(POSIX) • ereg (string pattern, string string [, array regs]) o Searches a string for matches to the regular expression given in pattern. • ereg_replace (string pattern, string subs, string string) o Scans string for matches to pattern, then replaces the matched text with subs. • array split (string pattern, string string [, int limit]) o Split string using pattern
  • 22. Regular ExprRegular Expr ereg ("abc", $string); ereg ("^abc", $string); ereg ("abc$", $string); eregi ("(ozilla.[23]|MSIE.3)", $HTTP_USER_AGENT); ereg ("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)", $string,$regs); $string = ereg_replace ("^", "<BR>", $string); $string = ereg_replace ("$", "<BR>", $string); $string = ereg_replace ("n", "", $string);
  • 23. Regular ExprRegular Expr if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) { echo "$regs[3].$regs[2].$regs[1]"; }else{ echo "Invalid date format: $date"; }
  • 24. Regular ExprRegular Expr $string = "This is a test"; echo ereg_replace (" is", " was", $string); echo ereg_replace ("( )is", "1was", $string); echo ereg_replace ("(( )is)", "2was", $string);
  • 25. Regular ExprRegular Expr $date = "04/30/1973"; // Delimiters may be slash, dot, or hyphen list ($month, $day, $year) = split ('[/.-]', $date); echo "Month: $month; Day: $day; Year: $year";
  • 26. ThankThank You !!!You !!! For More Information click below link: Follow Us on: http://vibranttechnologies.co.in/php-classes-in- mumbai.html