SlideShare a Scribd company logo
1 of 28
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Hidaya Institute of
Science &
Technology
www.histpk.org
A Division of Hidaya Trust, Pakistan
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
String Functions and Operations
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
What Is String?
A string is a data type used in programming, such as an integer and floating point
unit, but is used to represent text rather than numbers. It is comprised of a set of
characters that can also contain spaces and numbers. For example, the word
"hamburger" and the phrase "I ate 3 hamburgers" are both strings. Even "12345"
could be considered a string, if specified correctly. Typically, programmers must
enclose strings in quotation marks for the data to recognized as a string and not a
number or variable name.
•String is a collection of characters.
•String is a collection of ASCII characters.
•http://www.asciitable.com/
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
PHP chr() Function
The chr() function returns a character from the specified ASCII value.
Syntax
chr(ascii)
Example
<?php
echo chr(65);
echo chr(122);
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
PHP ord() Function
The ord() function returns the ASCII value of the first character of a string.
Syntax
ord(string)
Example
<?php
echo ord(“h”).”<br />”;
echo ord(“hello”).”<br />”;
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
PHP strlen() Function
The strlen() function is used to return the length of a string.
Syntax
strlen(string)
Example
<?php
echo strlen("Hello world!");
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
PHP substr() Function
The substr() function returns a part of a string.
Syntax
substr(string,start,length)
Example
<?php
echo substr("Hello world!",6);
echo substr("Hello world!",6,5);
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
PHP trim() Function
The trim() function removes whitespaces from both sides of a string.
Syntax
trim(string)
Example
<?php
echo trim(“ Hello World ”);
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 1
Enter String
Text
Click
Output
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 2 Enter String
Text
Click
Output
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 3
Enter String Text
Click
Output
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 4
Enter some
text here
Find
character
Replace
character
Click
Output
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 5
Enter Text
Click
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 5
Output
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 6
Characte
r
Output
Click
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 6
Characte
r
Output
Click
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 7
Enter Text
Click
Output
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
PHP rand() Function
The rand() function generates a random integer.
If this function is called without parameters, it returns a random integer
between 0 and RAND_MAX.
If you want a random number between 10 and 100 (inclusive), use rand
(10,100).
Note: On some platforms (such as Windows) RAND_MAX is only 32768. So,
if you require a range larger than 32768, you can specify min and max, or
use the mt_rand() function instead.
The other random function, mt_rand() function generates a better random
value than this function .
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
• PHP rand() Function continue……
• Syntax
rand(min,max)
Example 1
<?php
echo(rand() . "<br />");
echo(getrandmax(). "<br />");
echo(rand(10,100));
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
• PHP rand() Function continue……
• Example 2
<?php
echo "<hr> mt_rand = ".mt_rand()."<hr>";
echo "<hr>rand = ".rand()."<hr>";
echo "<hr> mt_rand with range = ".mt_rand(1,100)."<hr>";
echo "<hr> rand with range = ".rand(1,100)."<hr>";
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
• PHP round() function
• The round() function rounds a number to the
nearest integer.
• Syntax:
• round(x,prec)
Parameter Description
x Required. The number to be round
prec Optional. The number of digits after the decimal point
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
• PHP round() function continued….
• Example 1
• <?php
• echo round(1.68) ;
• ?>
• Example 2
• <?php
• echo round(1.68,1) ;
• ?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
• PHP ceil() function
• The ceil() function returns the value of a number rounded
UPWARDS to the nearest integer.
Syntax
Ceil(x)
Example:
<?php
echo ceil(0.60);
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
• PHP floor() Function
• The floor() function returns the value of a number rounded
DOWNWARDS to the nearest integer.
Syntax
floor(x)
Example:
<?php
echo floor(0.60);
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
PHP explode() Function
The explode() function breaks a string into an array.
Syntax
explode(separator,string)
Example
<?php
$string = "Hello world. It's a beautiful day.";
print_r (explode(" ",$string));
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
PHP implode() Function
The implode() function returns a string from the elements of an array.
Syntax
implode(separator,array)
Example
<?php
$array = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$array);
?>
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 8
Disabled Textbox Click Generate
Password
Output
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org
Assignment # 9
Enter
Word
Click
Output

More Related Content

Viewers also liked

Css presentation lecture 1
Css presentation lecture 1Css presentation lecture 1
Css presentation lecture 1Mudasir Syed
 
Javascript lecture 3
Javascript lecture 3Javascript lecture 3
Javascript lecture 3Mudasir Syed
 
Css presentation lecture 4
Css presentation lecture 4Css presentation lecture 4
Css presentation lecture 4Mudasir Syed
 
Form validation with built in functions
Form validation with built in functions Form validation with built in functions
Form validation with built in functions Mudasir Syed
 
Form validation server side
Form validation server side Form validation server side
Form validation server side Mudasir Syed
 
Javascript lecture 4
Javascript lecture  4Javascript lecture  4
Javascript lecture 4Mudasir Syed
 
loops and branches
loops and branches loops and branches
loops and branches Mudasir Syed
 
Web forms and html lecture Number 3
Web forms and html lecture Number 3Web forms and html lecture Number 3
Web forms and html lecture Number 3Mudasir Syed
 
introduction to programmin
introduction to programminintroduction to programmin
introduction to programminMudasir Syed
 
Form validation client side
Form validation client side Form validation client side
Form validation client side Mudasir Syed
 
Web forms and html lecture Number 2
Web forms and html lecture Number 2Web forms and html lecture Number 2
Web forms and html lecture Number 2Mudasir Syed
 

Viewers also liked (15)

Javascript 2
Javascript 2Javascript 2
Javascript 2
 
Css presentation lecture 1
Css presentation lecture 1Css presentation lecture 1
Css presentation lecture 1
 
Javascript lecture 3
Javascript lecture 3Javascript lecture 3
Javascript lecture 3
 
Sessions in php
Sessions in php Sessions in php
Sessions in php
 
Css presentation lecture 4
Css presentation lecture 4Css presentation lecture 4
Css presentation lecture 4
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
PHP array 1
PHP array 1PHP array 1
PHP array 1
 
Form validation with built in functions
Form validation with built in functions Form validation with built in functions
Form validation with built in functions
 
Form validation server side
Form validation server side Form validation server side
Form validation server side
 
Javascript lecture 4
Javascript lecture  4Javascript lecture  4
Javascript lecture 4
 
loops and branches
loops and branches loops and branches
loops and branches
 
Web forms and html lecture Number 3
Web forms and html lecture Number 3Web forms and html lecture Number 3
Web forms and html lecture Number 3
 
introduction to programmin
introduction to programminintroduction to programmin
introduction to programmin
 
Form validation client side
Form validation client side Form validation client side
Form validation client side
 
Web forms and html lecture Number 2
Web forms and html lecture Number 2Web forms and html lecture Number 2
Web forms and html lecture Number 2
 

Similar to String functions and operations

Reporting using FPDF
Reporting using FPDFReporting using FPDF
Reporting using FPDFMudasir Syed
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHPShweta A
 
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...Amazon Web Services
 
PHP 5.4 New Features
PHP 5.4 New FeaturesPHP 5.4 New Features
PHP 5.4 New FeaturesHaim Michael
 
20180420 hk-the powerofmysql8
20180420 hk-the powerofmysql820180420 hk-the powerofmysql8
20180420 hk-the powerofmysql8Ivan Ma
 
Python and the MySQL Document Store
Python and the MySQL Document StorePython and the MySQL Document Store
Python and the MySQL Document StoreJesper Wisborg Krogh
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonCodemotion
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python ProgrammingDozie Agbo
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersMohammed Mushtaq Ahmed
 
PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. wahidullah mudaser
 
High-level Programming Languages: Apache Pig and Pig Latin
High-level Programming Languages: Apache Pig and Pig LatinHigh-level Programming Languages: Apache Pig and Pig Latin
High-level Programming Languages: Apache Pig and Pig LatinPietro Michiardi
 
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Oracle Developers
 
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Amazon Web Services
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)Arjun Shanka
 
Custom Component development Oracle's Intelligent Bot Platform
Custom Component development Oracle's Intelligent Bot PlatformCustom Component development Oracle's Intelligent Bot Platform
Custom Component development Oracle's Intelligent Bot PlatformLeon Smiers
 

Similar to String functions and operations (20)

Reporting using FPDF
Reporting using FPDFReporting using FPDF
Reporting using FPDF
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHP
 
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
 
PHP 5.4 New Features
PHP 5.4 New FeaturesPHP 5.4 New Features
PHP 5.4 New Features
 
20180420 hk-the powerofmysql8
20180420 hk-the powerofmysql820180420 hk-the powerofmysql8
20180420 hk-the powerofmysql8
 
More about PHP
More about PHPMore about PHP
More about PHP
 
Python and the MySQL Document Store
Python and the MySQL Document StorePython and the MySQL Document Store
Python and the MySQL Document Store
 
TWINS: OOP and FP - Warburton
TWINS: OOP and FP - WarburtonTWINS: OOP and FP - Warburton
TWINS: OOP and FP - Warburton
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array.
 
High-level Programming Languages: Apache Pig and Pig Latin
High-level Programming Languages: Apache Pig and Pig LatinHigh-level Programming Languages: Apache Pig and Pig Latin
High-level Programming Languages: Apache Pig and Pig Latin
 
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
 
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Custom Component development Oracle's Intelligent Bot Platform
Custom Component development Oracle's Intelligent Bot PlatformCustom Component development Oracle's Intelligent Bot Platform
Custom Component development Oracle's Intelligent Bot Platform
 
Pa2 session 4
Pa2 session 4Pa2 session 4
Pa2 session 4
 

More from Mudasir Syed

Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php Mudasir Syed
 
Cookies in php lecture 2
Cookies in php  lecture  2Cookies in php  lecture  2
Cookies in php lecture 2Mudasir Syed
 
Cookies in php lecture 1
Cookies in php lecture 1Cookies in php lecture 1
Cookies in php lecture 1Mudasir Syed
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2Mudasir Syed
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2Mudasir Syed
 
Filing system in PHP
Filing system in PHPFiling system in PHP
Filing system in PHPMudasir Syed
 
Time manipulation lecture 2
Time manipulation lecture 2Time manipulation lecture 2
Time manipulation lecture 2Mudasir Syed
 
Time manipulation lecture 1
Time manipulation lecture 1 Time manipulation lecture 1
Time manipulation lecture 1 Mudasir Syed
 
Adminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminAdminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminMudasir Syed
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joinsMudasir Syed
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction databaseMudasir Syed
 
PHP mysql Installing my sql 5.1
PHP mysql  Installing my sql 5.1PHP mysql  Installing my sql 5.1
PHP mysql Installing my sql 5.1Mudasir Syed
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagramMudasir Syed
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatinMudasir Syed
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functionsMudasir Syed
 

More from Mudasir Syed (19)

Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
 
Cookies in php lecture 2
Cookies in php  lecture  2Cookies in php  lecture  2
Cookies in php lecture 2
 
Cookies in php lecture 1
Cookies in php lecture 1Cookies in php lecture 1
Cookies in php lecture 1
 
Ajax
Ajax Ajax
Ajax
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
 
Oop in php lecture 2
Oop in  php lecture 2Oop in  php lecture 2
Oop in php lecture 2
 
Filing system in PHP
Filing system in PHPFiling system in PHP
Filing system in PHP
 
Time manipulation lecture 2
Time manipulation lecture 2Time manipulation lecture 2
Time manipulation lecture 2
 
Time manipulation lecture 1
Time manipulation lecture 1 Time manipulation lecture 1
Time manipulation lecture 1
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
 
Adminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdminAdminstrating Through PHPMyAdmin
Adminstrating Through PHPMyAdmin
 
Sql select
Sql select Sql select
Sql select
 
PHP mysql Sql
PHP mysql  SqlPHP mysql  Sql
PHP mysql Sql
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joins
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction database
 
PHP mysql Installing my sql 5.1
PHP mysql  Installing my sql 5.1PHP mysql  Installing my sql 5.1
PHP mysql Installing my sql 5.1
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagram
 
PHP mysql Database normalizatin
PHP mysql  Database normalizatinPHP mysql  Database normalizatin
PHP mysql Database normalizatin
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 

String functions and operations

  • 1. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Hidaya Institute of Science & Technology www.histpk.org A Division of Hidaya Trust, Pakistan
  • 2. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org String Functions and Operations
  • 3. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org What Is String? A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. For example, the word "hamburger" and the phrase "I ate 3 hamburgers" are both strings. Even "12345" could be considered a string, if specified correctly. Typically, programmers must enclose strings in quotation marks for the data to recognized as a string and not a number or variable name. •String is a collection of characters. •String is a collection of ASCII characters. •http://www.asciitable.com/
  • 4. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org PHP chr() Function The chr() function returns a character from the specified ASCII value. Syntax chr(ascii) Example <?php echo chr(65); echo chr(122); ?>
  • 5. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org PHP ord() Function The ord() function returns the ASCII value of the first character of a string. Syntax ord(string) Example <?php echo ord(“h”).”<br />”; echo ord(“hello”).”<br />”; ?>
  • 6. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org PHP strlen() Function The strlen() function is used to return the length of a string. Syntax strlen(string) Example <?php echo strlen("Hello world!"); ?>
  • 7. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org PHP substr() Function The substr() function returns a part of a string. Syntax substr(string,start,length) Example <?php echo substr("Hello world!",6); echo substr("Hello world!",6,5); ?>
  • 8. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org PHP trim() Function The trim() function removes whitespaces from both sides of a string. Syntax trim(string) Example <?php echo trim(“ Hello World ”); ?>
  • 9. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 1 Enter String Text Click Output
  • 10. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 2 Enter String Text Click Output
  • 11. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 3 Enter String Text Click Output
  • 12. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 4 Enter some text here Find character Replace character Click Output
  • 13. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 5 Enter Text Click
  • 14. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 5 Output
  • 15. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 6 Characte r Output Click
  • 16. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 6 Characte r Output Click
  • 17. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 7 Enter Text Click Output
  • 18. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org PHP rand() Function The rand() function generates a random integer. If this function is called without parameters, it returns a random integer between 0 and RAND_MAX. If you want a random number between 10 and 100 (inclusive), use rand (10,100). Note: On some platforms (such as Windows) RAND_MAX is only 32768. So, if you require a range larger than 32768, you can specify min and max, or use the mt_rand() function instead. The other random function, mt_rand() function generates a better random value than this function .
  • 19. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org • PHP rand() Function continue…… • Syntax rand(min,max) Example 1 <?php echo(rand() . "<br />"); echo(getrandmax(). "<br />"); echo(rand(10,100)); ?>
  • 20. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org • PHP rand() Function continue…… • Example 2 <?php echo "<hr> mt_rand = ".mt_rand()."<hr>"; echo "<hr>rand = ".rand()."<hr>"; echo "<hr> mt_rand with range = ".mt_rand(1,100)."<hr>"; echo "<hr> rand with range = ".rand(1,100)."<hr>"; ?>
  • 21. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org • PHP round() function • The round() function rounds a number to the nearest integer. • Syntax: • round(x,prec) Parameter Description x Required. The number to be round prec Optional. The number of digits after the decimal point
  • 22. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org • PHP round() function continued…. • Example 1 • <?php • echo round(1.68) ; • ?> • Example 2 • <?php • echo round(1.68,1) ; • ?>
  • 23. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org • PHP ceil() function • The ceil() function returns the value of a number rounded UPWARDS to the nearest integer. Syntax Ceil(x) Example: <?php echo ceil(0.60); ?>
  • 24. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org • PHP floor() Function • The floor() function returns the value of a number rounded DOWNWARDS to the nearest integer. Syntax floor(x) Example: <?php echo floor(0.60); ?>
  • 25. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org PHP explode() Function The explode() function breaks a string into an array. Syntax explode(separator,string) Example <?php $string = "Hello world. It's a beautiful day."; print_r (explode(" ",$string)); ?>
  • 26. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org PHP implode() Function The implode() function returns a string from the elements of an array. Syntax implode(separator,array) Example <?php $array = array('Hello','World!','Beautiful','Day!'); echo implode(" ",$array); ?>
  • 27. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 8 Disabled Textbox Click Generate Password Output
  • 28. © Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● www.hidayatrust.org / www,histpk.org Assignment # 9 Enter Word Click Output