Академический Документы
Профессиональный Документы
Культура Документы
DOCTYPE html>
<html lang="en-US">
<head><title>PHP 5 Strings</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Keywords"
content="HTML,CSS,JavaScript,SQL,PHP,jQuery,XML,DOM,Bootstrap,Python,Java,Web
development,W3C,tutorials,programming,training,learning,quiz,primer,lessons,referen
ces,examples,exercises,source code,colors,demos,tips">
<meta name="Description" content="Well organized and easy to understand Web
building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL,
PHP, Python, Bootstrap, Java and XML.">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/w3css/4/w3.css">
<link href='https://fonts.googleapis.com/css?family=Source Code Pro'
rel='stylesheet'>
<style>
a:hover,a:active{color:#4CAF50}
table.w3-table-all{margin:20px 0}
/*OPPSETT AV TOP, TOPNAV, SIDENAV, MAIN, RIGHT OG FOOTER:*/
.top {
position:relative;
background-color:#ffffff;
height:68px;
padding-top:20px;
line-height:50px;
overflow:hidden;
z-index:2;
}
.w3schools-logo {
font-family:fontawesome;
text-decoration:none;
line-height:1;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
font-size:37px;
letter-spacing:3px;
color:#555555;
display:block;
position:absolute;
top:17px;
}
.w3schools-logo .dotcom {color:#4CAF50}
.topnav {
position:relative;
z-index:2;
font-size:17px;
background-color:#5f5f5f;
color:#f1f1f1;
width:100%;
padding:0;
letter-spacing:1px;
font-family:"Segoe UI",Arial,sans-serif;
}
.topnav a{
padding:10px 15px 9px 15px !important;
}
.topnav .w3-bar a:hover,.topnav .w3-bar a:focus{
background-color:#000000 !important;
color:#ffffff !important;
}
.topnav .w3-bar a.active {
background-color:#4CAF50;
color:#ffffff;
}
a.topnav-icons {
width:52px !important;
font-size:20px !important;
padding-top:11px !important;
padding-bottom:13px !important;
}
a.topnav-icons.fa-home {font-size:22px !important}
a.topnav-icons.fa-menu {font-size:22px !important}
a.topnav-localicons {
font-size:20px !important;
padding-top:6px !important;
padding-bottom:12px !important;
}
i.fa-caret-down,i.fa-caret-up{width:10px}
#sidenav h2 {
font-size:21px;
padding-left:16px;
margin:-4px 0 4px 0;
width:204px;
}
#sidenav a {font-family:"Segoe UI",Arial,sans-serif;text-
decoration:none;display:block;padding:2px 1px 1px 16px}
#sidenav a:hover,#sidenav a:focus {color:#000000;background-color:#cccccc;}
#sidenav a.active {background-color:#4CAF50;color:#ffffff}
#sidenav a.activesub:link,#sidenav a.activesub:visited {background-
color:#ddd;color:#000;}
#sidenav a.activesub:hover,#sidenav a.activesub:active {background-
color:#ccc;color:#000;}
#leftmenuinner {
position:fixed;
top:0;
padding-top:112px;
padding-bottom:0;
height:100%;
width:220px;
background-color:transparent;
}
#leftmenuinnerinner {
height:100%;
width:100%;
overflow-y:scroll;
overflow-x:hidden;
padding-top:20px;
}
#main {padding:16px}
#mainLeaderboard {height:90px}
#right {text-align:center;padding:16px 16px 0 0}
#right a {text-decoration:none}
#right a:hover {text-decoration:underline}
#skyscraper {min-height:600px}
.sidesection {margin-bottom:32px;}
#sidesection_exercise a{display:block;padding:4px 10px;}
#sidesection_exercise a:hover,#sidesection_exercise a:active{background-
color:#ccc;text-decoration:none;color:#000000;}
.bottomad {padding:0 16px 16px 0;float:left;width:auto;}
.footer a {text-decoration:none;}
.footer a:hover{text-decoration:underline;}
#nav_tutorials,#nav_references,#nav_exercises{-webkit-overflow-
scrolling:touch;overflow:auto;}
#nav_tutorials::-webkit-scrollbar,#nav_references::-webkit-
scrollbar,#nav_exercises::-webkit-scrollbar {width: 12px;}
#nav_tutorials::-webkit-scrollbar-track,#nav_references::-webkit-scrollbar-
track,#nav_exercises::-webkit-scrollbar-track {background:#555555;}
#nav_tutorials::-webkit-scrollbar-thumb,#nav_references::-webkit-scrollbar-
thumb,#nav_exercises::-webkit-scrollbar-thumb {background: #999999;}
#nav_tutorials,#nav_references,#nav_exercises {
display:none;
letter-spacing:0;
margin-top:44px;
}
#nav_tutorials a,#nav_references a,#nav_exercises a{
padding:2px 0 2px 6px!important;
}
#nav_tutorials a:focus,#nav_references a:focus,#nav_exercises a:focus{
color: #000;
background-color: #ccc;
}
#nav_tutorials h3,#nav_references h3,#nav_exercises h3{
padding-left:6px;
}
.ref_overview{display:none}
.w3-example{background-color:#f1f1f1;padding:0.01em 16px;margin:20px 0;box-shadow:0
2px 4px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)!important}
.nextprev a {font-size:17px;border:1px solid #cccccc;}
.nextprev a:link,.nextprev a:visited {background-color:#ffffff;color:#000000;}
.w3-example a:focus,.nextprev a:focus{box-shadow:0 8px 16px 0 rgba(0,0,0,0.2), 0
6px 20px 0 rgba(0,0,0,0.19);}
.nextprev a.w3-right,.nextprev a.w3-left {background-
color:#4CAF50;color:#ffffff;border-color:#4CAF50}
#w3-exerciseform {background-color:#555555;padding:16px;color:#ffffff;}
#w3-exerciseform .exercisewindow {background-
color:#ffffff;padding:16px;color:#000000;}
#w3-exerciseform .exerciseprecontainer {background-color:#f1f1f1;padding:16px;font-
size:120%;font-family:Consolas,"Courier New", Courier, monospace;}
#w3-exerciseform .exerciseprecontainer pre {display: block;}
#w3-exerciseform .exerciseprecontainer input {padding:1px;border: 1px solid
transparent;height:1.3em;}
.w3-theme {color:#fff !important;background-color:#73AD21 !important;background-
color:#4CAF50 !important}
.w3-theme-border {border-color:#4CAF50 !important}
.sharethis a:hover {color:inherit;}
.fa-facebook-square,.fa-twitter-square,.fa-google-plus-square {padding:0 8px;}
.fa-facebook-square:hover, .fa-thumbs-o-up:hover {color:#3B5998;}
.fa-twitter-square:hover {color:#55acee;}
.fa-google-plus-square:hover {color:#dd4b39;}
#google_translate_element img {margin-bottom:-1px;}
#googleSearch {color:#000000;}
#googleSearch a {padding:0 !important;}
.searchdiv {max-width:400px;margin:auto;text-align:left;font-size:16px}
div.cse .gsc-control-cse, div.gsc-control-cse {background-
color:transparent;border:none;padding:6px;margin:0px}
td.gsc-search-button input.gsc-search-button {background-color:#4CAF50;border-
color:#4CAF50}
td.gsc-search-button input.gsc-search-button:hover {background-color:#46a049;}
input.gsc-input, .gsc-input-box, .gsc-input-box-hover, .gsc-input-box-focus, .gsc-
search-button {
box-sizing:content-box; line-height:normal;}
.gsc-tabsArea div {overflow:visible;}
/*"nullstille" w3css:*/
.w3-main{transition:margin-left 0s;}
/*"nullstilling" slutt*/
@media (min-width:1675px) {
#main {width:79%}
#right {width:21%}
}
@media (max-width:992px) {
.top {height:100px}
.top img {display:block;margin:auto;}
.top .w3schools-logo {position:relative;top:0;width:100%;text-
align:center;margin:auto}
.toptext {width:100%;text-align:center}
#sidenav {width:260px;
box-shadow:0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
#sidenav h2 {font-size:26px;width:100%;}
#sidenav a {padding:3px 2px 3px 24px;font-size:17px}
#leftmenuinner {
overflow:auto;
-webkit-overflow-scrolling:touch;
height:100%;
position:relative;
width:auto;
padding-top:0;
background-color:#f1f1f1;
}
#leftmenuinnerinner {overflow-y:scroll}
.bottomad {float:none;text-align:center}
#skyscraper {min-height:60px}
}
@media screen and (max-width:600px) {
.w3-example, .w3-note, #w3-exerciseform {margin-left:-16px;margin-right:-16px;}
.top {height:68px}
.toptext {display:none}
}
@font-face {
font-family:'fontawesome';
src: url('../lib/fonts/fontawesome.eot?14663396');
src:url('../lib/fonts/fontawesome.eot?14663396#iefix') format('embedded-opentype'),
url('../lib/fonts/fontawesome.woff?14663396') format('woff'),
url('../lib/fonts/fontawesome.ttf?14663396') format('truetype'),
url('../lib/fonts/fontawesome.svg?14663396#fontawesome') format('svg');
font-weight:normal;
font-style:normal;
}
.fa {
display:inline-block;
font:normal normal normal 14px/1 FontAwesome;
font-size:inherit;
text-rendering:auto;
-webkit-font-smoothing:antialiased;
-moz-osx-font-smoothing:grayscale;
transform:translate(0, 0);
}
.fa-2x {
font-size:2em;
}
.fa-home:before {content:'\e800';}
.fa-menu:before {content: '\f0c9';}
.fa-globe:before {content:'\e801';}
.fa-search:before {content:'\e802'; }
.fa-thumbs-o-up:before {content:'\e803';}
.fa-left-open:before {content:'\e804';}
.fa-right-open:before {content:'\e805';}
.fa-facebook-square:before {content:'\e806';}
.fa-google-plus-square:before {content:'\e807';}
.fa-twitter-square:before {content:'\e808';}
.fa-caret-down:before {content:'\e809';}
.fa-caret-up:before {content:'\e80a';}
.fa-adjust:before { content: '\e80b'; }
span.marked, span.deprecated {
color:#e80000;
background-color:transparent;
}
.intro {font-size:16px}
.w3-btn, .w3-btn:link, .w3-btn:visited {color:#FFFFFF;background-color:#4CAF50}
a.w3-btn[href*="exercise.asp"],a.w3-btn[href*="exercise_js.asp"] {margin:10px 5px 0
0}
a.btnplayit,a.btnplayit:link,a.btnplayit:visited {background-
color:#FFAD33;padding:1px 10px 2px 10px}
a.btnplayit:hover,a.btnplayit:active {background-color:#ffffff;color:#FFAD33}
a.btnplayit:hover {box-shadow:0 4px 8px 0 rgba(0,0,0,0.2);}
a.btnsmall:link,a.btnsmall:visited,a.btnsmall:active,a.btnsmall:hover {
float:right;padding:1px 10px 2px 10px;font:15px Verdana, sans-serif;}
a.btnsmall:hover {box-shadow:0 4px 8px 0 rgba(0,0,0,0.2);}
a.btnsmall:active,a.btnsmall:hover {color:#4CAF50;background-color:#ffffff}
.tagcolor{color:mediumblue}
.tagnamecolor{color:brown}
.attributecolor{color:red}
.attributevaluecolor{color:mediumblue}
.commentcolor{color:green}
.cssselectorcolor{color:brown}
.csspropertycolor{color:red}
.csspropertyvaluecolor{color:mediumblue}
.cssdelimitercolor{color:black}
.cssimportantcolor{color:red}
.jscolor{color:black}
.jskeywordcolor{color:mediumblue}
.jsstringcolor{color:brown}
.jsnumbercolor{color:red}
.jspropertycolor{color:black}
.javacolor{color:black}
.javakeywordcolor{color:mediumblue}
.javastringcolor{color:brown}
.javanumbercolor{color:red}
.javapropertycolor{color:black}
.kotlincolor{color:black}
.kotlinkeywordcolor{color:mediumblue}
.kotlinstringcolor{color:brown}
.kotlinnumbercolor{color:red}
.kotlinpropertycolor{color:black}
.phptagcolor{color:red}
.phpcolor{color:black}
.phpkeywordcolor{color:mediumblue}
.phpglobalcolor{color:goldenrod}
.phpstringcolor{color:brown}
.phpnumbercolor{color:red}
.pythoncolor{color:black}
.pythonkeywordcolor{color:mediumblue}
.pythonstringcolor{color:brown}
.pythonnumbercolor{color:red}
.angularstatementcolor{color:red}
.sqlcolor{color:black}
.sqlkeywordcolor{color:mediumblue}
.sqlstringcolor{color:brown}
.sqlnumbercolor{color:}
.darktheme {background-color:rgb(40,44,52);color:white;}
.darktheme .tagcolor{color:#88ccbb/*green2*/!important}
.darktheme .tagnamecolor{color:#ff9999/*red*/!important}
.darktheme .attributecolor{color:#c5a5c5/*purple*/!important}
.darktheme .attributevaluecolor{color:#88c999/*green*/!important}
.darktheme .commentcolor{color:color: #999;!important}
.darktheme .cssselectorcolor{color:#ff9999/*red*/!important}
.darktheme .csspropertycolor{color:#c5a5c5/*purple*/!important}
.darktheme .csspropertyvaluecolor{color:#88c999/*green*/!important}
.darktheme .cssdelimitercolor{color:white!important}
.darktheme .cssimportantcolor{color:color:#ff9999/*red*/!important}
.darktheme .jscolor{color:white!important}
.darktheme .jskeywordcolor{color:#c5a5c5/*purple*/!important}
.darktheme .jsstringcolor{color:#88c999/*green*/!important}
.darktheme .jsnumbercolor{color:#80b6ff/*blue*/!important}
.darktheme .jspropertycolor{color:white!important}
.darktheme .javacolor{color:white!important}
.darktheme .javakeywordcolor{color:#88c999/*green*/!important}
.darktheme .javastringcolor{color:#88c999/*green*/!important}
.darktheme .javanumbercolor{color:#88c999/*green*/!important}
.darktheme .javapropertycolor{color:white!important}
.darktheme .kotlincolor{color:white!important}
.darktheme .kotlinkeywordcolor{color:#88c999/*green*/!important}
.darktheme .kotlinstringcolor{color:#88c999/*green*/!important}
.darktheme .kotlinnumbercolor{color:#88c999/*green*/!important}
.darktheme .kotlinpropertycolor{color:white!important}
.darktheme .phptagcolor{color:#999!important}
.darktheme .phpcolor{color:white!important}
.darktheme .phpkeywordcolor{color:#ff9999/*red*/!important}
.darktheme .phpglobalcolor{color:white!important}
.darktheme .phpstringcolor{color:color:#88c999/*green*/!important}
.darktheme .phpnumbercolor{color:#88c999/*green*/!important}
.darktheme .pythoncolor{color:white!important}
.darktheme .pythonkeywordcolor{color:#ff9999/*red*/!important}
.darktheme .pythonstringcolor{color:#88c999/*green*/!important}
.darktheme .pythonnumbercolor{color:#88c999/*green*/!important}
.darktheme .angularstatementcolor{color:#ff9999/*red*/!important}
.darktheme .sqlcolor{color:white!important}
.darktheme .sqlkeywordcolor{color:#80b6ff/*blue*/!important}
.darktheme .sqlstringcolor{color:#88c999/*green*/!important}
.darktheme .sqlnumbercolor{color:}
@media only screen and (max-device-width: 480px) {
.w3-code, .w3-codespan,#w3-exerciseform .exerciseprecontainer {font-family: 'Source
Code Pro',Menlo,Consolas,monospace;}
.w3-code {font-size:14px;}
.w3-codespan {font-size:15px;}
#w3-exerciseform .exerciseprecontainer {font-size:15px;}
#w3-exerciseform .exerciseprecontainer input {padding:0;height:1.5em}
}
@media screen and (max-width:700px) {
#mainLeaderboard {height:60px}
#div-gpt-ad-1422003450156-0 {float:none;margin-left:auto;margin-right:auto}
#div-gpt-ad-1422003450156-3 {float:none;margin-left:auto;margin-right:auto}
}
@media (max-width:1700px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(17)
{display:none;}}
@media (max-width:1600px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(13)
{display:none;}}
@media (max-width:1510px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(12)
{display:none;}}
@media (max-width:1450px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(11)
{display:none;}}
@media (max-width:1330px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(10)
{display:none;}}
@media (max-width:1200px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(9)
{display:none;}}
@media (max-width:1100px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(8)
{display:none;}}
@media (max-width:1000px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(7)
{display:none;}}
@media (max-width:992px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(6)
{display:none;}}
@media (max-width:930px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(18)
{display:none;}}
@media (max-width:800px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(19)
{display:none;}}
@media (max-width:650px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(5)
{display:none;} #topnav .w3-bar:nth-of-type(1) a:nth-of-type(16){display:none;}}
@media (max-width:460px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(4)
{display:none;}}
@media (max-width:400px) {#topnav .w3-bar:nth-of-type(1) a:nth-of-type(3)
{display:none;}}
.w3-note{background-color:#ffffcc;border-left:6px solid #ffeb3b}
.w3-warning{background-color:#ffdddd;border-left:6px solid #f44336}
.w3-info{background-color:#ddffdd;border-left:6px solid #4CAF50}
hr[id^="ez-insert-after-placeholder"] {margin-top: 0;}
.phonebr {display:none;}
@media screen and (max-width: 475px) {.phonebr {display:initial;}}
</style>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-3855518-1', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
k42 = true;
(adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=1;
</script>
<script src="//static.h-bid.com/sncmp/sncmp_stub.min.js"
type="text/javascript"></script>
<script>
window.__cmp('setLogo',
"//www.w3schools.com/images/w3schoolscom_gray.gif", function(result){
snhb.console.log("Logo set");
});
window.__cmp('setPrivacyPolicy',
"//www.w3schools.com/about/about_privacy.asp", function(result){
snhb.console.log("Privacy policy URI set");
});
window.__cmp('enableBanner', null, function(result) {
snhb.console.log("Banner mode enabled");
});
__cmp('enablePopupDismissable', null, function(result) {});
window.__cmp('disableBannerPrivacyPolicyButton', null,
function(result) {
snhb.console.log("Banner mode without privacy policy button
enabled");
});
window.__cmp('setTranslationFiles', { path: '//www.w3schools.com/lib/',
locales: ["en"] }, function(result) {});
__cmp('setCSS', '//www.w3schools.com/lib/cmp.css', function(result){} );
</script>
<script async type="text/javascript" src="//static.h-
bid.com/w3schools.com/20190327/snhb-w3schools.com.min.js?20190327"></script>
<script>
snhb.queue.push(function(){
snhb.startAuction(["main_leaderboard", "wide_skyscraper",
"bottom_medium_rectangle", "right_bottom_medium_rectangle"]);
});
</script>
<script type='text/javascript'>
var stickyadstatus = "";
function fix_stickyad() {
document.getElementById("stickypos").style.position = "sticky";
var elem = document.getElementById("stickyadcontainer");
if (!elem) {return false;}
if (document.getElementById("skyscraper")) {
var skyWidth = Number(w3_getStyleValue(document.getElementById("skyscraper"),
"width").replace("px", ""));
}
else {
var skyWidth = Number(w3_getStyleValue(document.getElementById("right"),
"width").replace("px", ""));
}
elem.style.width = skyWidth + "px";
if (window.innerWidth <= 992) {
elem.style.position = "";
elem.style.top = stickypos + "px";
return false;
}
var stickypos = document.getElementById("stickypos").offsetTop;
var docTop = window.pageYOffset || document.documentElement.scrollTop ||
document.body.scrollTop;
var adHeight = Number(w3_getStyleValue(elem, "height").replace("px", ""));
if (stickyadstatus == "") {
if ((stickypos - docTop) < 60) {
elem.style.position = "fixed";
elem.style.top = "60px";
stickyadstatus = "sticky";
document.getElementById("stickypos").style.position = "sticky";
}
} else {
if ((docTop + 60) - stickypos < 0) {
elem.style.position = "";
elem.style.top = stickypos + "px";
stickyadstatus = "";
document.getElementById("stickypos").style.position = "static";
}
}
if (stickyadstatus == "sticky") {
if ((docTop + adHeight + 60) > document.getElementById("footer").offsetTop) {
elem.style.position = "absolute";
elem.style.top = (document.getElementById("footer").offsetTop - adHeight) +
"px";
document.getElementById("stickypos").style.position = "static";
} else {
elem.style.position = "fixed";
elem.style.top = "60px";
stickyadstatus = "sticky";
document.getElementById("stickypos").style.position = "sticky";
}
}
}
function w3_getStyleValue(elmnt,style) {
if (window.getComputedStyle) {
return window.getComputedStyle(elmnt,null).getPropertyValue(style);
} else {
return elmnt.currentStyle[style];
}
}
</script>
</head><body>
<div class='w3-container top'>
<a class='w3schools-logo notranslate' href='//www.w3schools.com'>w3schools<span
class='dotcom'>.com</span></a>
<div class='w3-right w3-hide-small w3-wide toptext' style="font-family:'Segoe
UI',Arial,sans-serif">THE WORLD'S LARGEST WEB DEVELOPER SITE</div>
</div>
<div style='display:none;position:absolute;z-
index:4;right:52px;height:44px;background-color:#5f5f5f;letter-spacing:normal;'
id='googleSearch'>
<div class='gcse-search'></div>
</div>
<div style='display:none;position:absolute;z-
index:3;right:111px;height:44px;background-color:#5f5f5f;text-align:right;padding-
top:9px;' id='google_translate_element'></div>
<br><br>
</div>
</div>
</div>
<div class='w3-main w3-light-grey' id='belowtopnav' style='margin-left:220px;'>
<div class='w3-row w3-white'>
<div class='w3-col l10 m12' id='main'>
<div id='mainLeaderboard' style='overflow:hidden;'>
<!-- MainLeaderboard-->
</div>
<h1>PHP 5 <span class="color_h1">Strings</span></h1>
<div class="w3-clear nextprev">
<a class="w3-left w3-btn" href="php_datatypes.asp">❮ Previous</a>
<a class="w3-right w3-btn" href="php_constants.asp">Next ❯</a>
</div>
<hr>
<p class="intro">A string is a sequence of characters, like "Hello world!
".</p>
<hr>
<p>In this chapter we will look at some commonly used functions to manipulate
strings.</p>
<hr>
<div class="w3-example">
<h3>Example</h3>
<div class="w3-code htmlHigh notranslate">
<?php<br>
echo strlen("Hello world!"); // outputs 12<br>
?>
</div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="showphp.asp?
filename=demo_string_length">Run example »</a>
</div>
<div class="w3-example">
<h3>Example</h3>
<div class="w3-code htmlHigh notranslate">
<?php<br>
echo str_word_count("Hello world!"); // outputs 2<br>
?>
</div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="showphp.asp?
filename=demo_string_word_count">Run example »</a>
</div>
</div>
<hr>
<h2>Reverse a String</h2>
<p>The PHP <code class="w3-codespan">strrev()</code> function reverses a
string:</p>
<div class="w3-example">
<h3>Example</h3>
<div class="w3-code htmlHigh notranslate">
<?php<br>
echo strrev("Hello world!"); // outputs !dlrow olleH<br>
?>
</div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="showphp.asp?
filename=demo_string_reverse">Run example »</a>
</div>
<div class="w3-example">
<h3>Example</h3>
<div class="w3-code htmlHigh notranslate">
<?php<br>
echo strpos("Hello world!", "world"); // outputs 6<br>
?>
</div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="showphp.asp?
filename=demo_string_pos">Run example »</a>
</div>
<div class="w3-example">
<h3>Example</h3>
<div class="w3-code htmlHigh notranslate">
<?php<br>
echo str_replace("world", "Dolly", "Hello world!
"); // outputs Hello Dolly!<br>
?>
</div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="showphp.asp?
filename=demo_string_replace">Run example »</a>
</div>
<div class="sidesection">
<div id="skyscraper">
</div>
</div>
<div class="sidesection">
<h4><a href="/colors/colors_picker.asp">COLOR PICKER</a></h4>
<a href="/colors/colors_picker.asp">
<img src="/images/colorpicker.gif" alt="colorpicker"></a>
</div>
<!--
<div id="sidesection_exercise" class="sidesection" style="background-
color:#555555;max-width:200px;margin:auto;margin-bottom:32px">
<div class="w3-container w3-text-white">
<h4>Exercises</h4>
</div>
<div>
<div class="w3-light-grey">
<a target="_blank" href="/html/exercise.asp" style="padding-top:8px">HTML</a>
<a target="_blank" href="/css/exercise.asp">CSS</a>
<a target="_blank" href="/js/exercise_js.asp">JavaScript</a>
<a target="_blank" href="/sql/exercise.asp">SQL</a>
<a target="_blank" href="/php/exercise.asp">PHP</a>
<a target="_blank" href="/python/exercise.asp">Python</a>
<a target="_blank" href="/bootstrap/exercise_bs3.asp">Bootstrap</a>
<a target="_blank" href="/jquery/exercise_jq.asp" style="padding-
bottom:8px">jQuery</a>
</div>
</div>
</div>
-->
<div class="sidesection">
<h4>SHARE</h4>
<div class="w3-text-grey sharethis">
<script>
<!--
try{
loc=location.pathname;
if (loc.toUpperCase().indexOf(".ASP")<0) loc=loc+"default.asp";
txt='<a href="http://www.facebook.com/sharer.php?
u=https://www.w3schools.com'+loc+'" target="_blank" title="Facebook"><span
class="fa fa-facebook-square fa-2x"></span></a>';
txt=txt+'<a href="https://twitter.com/home?status=Currently reading
https://www.w3schools.com'+loc+'" target="_blank" title="Twitter"><span class="fa
fa-twitter-square fa-2x"></span></a>';
document.write(txt);
} catch(e) {}
//-->
</script>
<br><br>
<a href="javascript:void(0);" onclick="clickFBLike()" title="Like W3Schools on
Facebook">
<span class="fa fa-thumbs-o-up fa-2x"></span></a>
<div id="fblikeframe" class="w3-modal">
<div class="w3-modal-content w3-padding-64 w3-animate-zoom" id="popupDIV"></div>
</div>
</div>
</div>
<div class="sidesection">
<h4><a target="_blank"
href="//www.w3schools.com/cert/default.asp">CERTIFICATES</a></h4>
<p>
<a href="/cert/cert_html.asp">HTML</a><br>
<a href="/cert/cert_css.asp">CSS</a><br>
<a href="/cert/cert_javascript.asp">JavaScript</a><br>
<a href="/cert/cert_sql.asp">SQL</a><br>
<a href="/cert/cert_python.asp">Python</a><br>
<a href="/cert/cert_php.asp">PHP</a><br>
<a href="/cert/cert_jquery.asp">jQuery</a><br>
<a href="/cert/cert_bootstrap.asp">Bootstrap</a><br>
<a href="/cert/cert_xml.asp">XML</a></p>
<a href="//www.w3schools.com/cert/default.asp" class="w3-button w3-dark-grey"
style="text-decoration:none">
Read More »</a>
</div>
</div>
</div>
</div>
<script>
window.addEventListener("scroll", fix_stickyad);
window.addEventListener("resize", fix_stickyad);
</script>
</div>
</div>
<div id="footer" class="footer w3-container w3-white">
<hr>
<div style="overflow:auto">
<div class="bottomad">
<!-- BottomMediumRectangle -->
<!--<pre>bottom_medium_rectangle, all: [970,250][300,250][336,280]</pre>-->
<div id="snhb-bottom_medium_rectangle-0" style="padding:0 10px 10px
0;float:left;width:auto;"></div>
<!-- adspace bmr -->
<!-- RightBottomMediumRectangle -->
<!--<pre>right_bottom_medium_rectangle, desktop: [300,250][336,280]</pre>-->
<div id="snhb-right_bottom_medium_rectangle-0" style="padding:0 10px 10px
0;float:left;width:auto;"></div>
</div>
</div>
<hr>
<div class="w3-row-padding w3-center w3-small" style="margin:0 -16px">
<div class="w3-col l3 m3 s12">
<a class="w3-button w3-light-grey w3-block" href="javascript:void(0);"
onclick="displayError();return false" style="white-space:nowrap;text-
decoration:none;margin-top:1px;margin-bottom:1px">REPORT ERROR</a>
</div>
<div class="w3-col l3 m3 s12">
<a class="w3-button w3-light-grey w3-block" href="javascript:void(0);"
target="_blank" onclick="printPage();return false;" style="text-
decoration:none;margin-top:1px;margin-bottom:1px">PRINT PAGE</a>
</div>
<div class="w3-col l3 m3 s12">
<a class="w3-button w3-light-grey w3-block" href="/forum/default.asp"
target="_blank" style="text-decoration:none;margin-top:1px;margin-
bottom:1px">FORUM</a>
</div>
<div class="w3-col l3 m3 s12">
<a class="w3-button w3-light-grey w3-block" href="/about/default.asp" target="_top"
style="text-decoration:none;margin-top:1px;margin-bottom:1px">ABOUT</a>
</div>
</div>
<hr>
<div class="w3-light-grey w3-padding w3-margin-bottom" id="err_form"
style="display:none;position:relative">
<span onclick="this.parentElement.style.display='none'" class="w3-button w3-
display-topright w3-large">×</span>
<h2>Your Suggestion:</h2>
<form>
<div class="w3-section">
<label for="err_email">Your E-mail:</label>
<input class="w3-input w3-border" type="text" style="margin-top:5px;width:100%"
id="err_email" name="err_email">
</div>
<div class="w3-section">
<label for="err_email">Page address:</label>
<input class="w3-input w3-border" type="text" style="width:100%;margin-top:5px"
id="err_url" name="err_url" disabled="disabled">
</div>
<div class="w3-section">
<label for="err_email">Description:</label>
<textarea rows="10" class="w3-input w3-border" id="err_desc" name="err_desc"
style="width:100%;margin-top:5px;resize:vertical;"></textarea>
</div>
<div class="form-group">
<button type="button" class="w3-button w3-dark-grey"
onclick="sendErr()">Submit</button>
</div>
<br>
</form>
</div>
<div class="w3-container w3-light-grey w3-padding" id="err_sent"
style="display:none;position:relative">
<span onclick="this.parentElement.style.display='none'" class="w3-button w3-
display-topright">×</span>
<h2>Thank You For Helping Us!</h2>
<p>Your message has been sent to W3Schools.</p>
</div>
</div>
</div>
</div>
<hr>
<div class="w3-center w3-small w3-opacity">
W3Schools is optimized for learning, testing, and training. Examples might be
simplified to improve reading and basic understanding.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness of all content.
While using this site, you agree to have read and accepted our <a
href="/about/about_copyright.asp">terms of use</a>,
<a href="/about/about_privacy.asp">cookie and privacy policy</a>.
<a href="/about/about_copyright.asp">Copyright 1999-2019</a> by Refsnes Data. All
Rights Reserved.<br>
<a href="//www.w3schools.com/w3css/">Powered by W3.CSS</a>.<br><br>
<a href="//www.w3schools.com">
<img style="width:150px;height:28px;border:0" src="/images/w3schoolscom_gray.gif"
alt="W3Schools.com"></a>
</div>
<br><br>
</div>
</div>
<script src="/lib/w3schools_footer.js"></script>
<script src="https://translate.google.com/translate_a/element.js?
cb=googleTranslateElementInit"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</body>
</html>