Programming Basics
  Home arrow Programming Basics arrow Page 23 - PHP Strings Primer
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PROGRAMMING BASICS

PHP Strings Primer
By: Matt Wade
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2003-07-11

    Table of Contents:
  • PHP Strings Primer
  • The Basics
  • Single Quotes
  • Double Quotes
  • Heredoc
  • Concatenation
  • Displaying Strings
  • echo
  • print
  • printf
  • Strings Formatting
  • Preparing user input for comparisons
  • Capitalization
  • Reversing strings
  • Padding strings
  • Multiple Lines
  • Data Preparation
  • Adding and Removing Slashes
  • Dealing with HTML Tags and Entities
  • Counting
  • Checking password strength
  • Generating Statistics
  • Substrings (and searching)
  • Extracting Substrings
  • Counting Paragraphs
  • Filtering Words
  • Working with email addresses
  • Manually Stripping Tags
  • Password Strength Revisited
  • Handling URLs and Base64-encoding
  • Parsing URLs
  • Encoding for URLs
  • Encoding for Email
  • Hashing
  • Verifying Integrity
  • User Authentication
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PHP Strings Primer - Substrings (and searching)


    (Page 23 of 37 )

    Many varied tasks can be accomplished by using substrings. We will define a substring as a string that makes up any portion of another string. This could be as small as a single character, or as large as the entire length of the string. In this section, we will examine different methods for finding substrings, replacing those substrings, and other related duties. First, let's take a look at the functions covered in this section.

  • substr(string, start [, length]) -Using this function, we can extract parts of a string to store in another string, or utilize in other functions.
  • substr_count(haystack, needle) -This function allows us to count the number of times a substring occurs within a string.
  • str_replace(haystack, replacement, needle) -With this function, we can replace all occurrences of a substring within a string with a different string.
  • substr_replace(string, replacement, start [, length]) -This is a different method of replacing portions of a string based on positions rather than searching for a substring.
  • strstr(haystack, needle) -Also called 'strchr', this function will find the first occurrence of a substring and return the portion of the string from that occurrence on.
  • stristr(haystack, needle) -This provides the same functionality as 'strstr', but searches in a case-insensitive manner.
  • strrchr(haystack, needle) -This function is identical to strstr', except that it finds the last occurrence of a substring instead of the first.
  • strpos(haystack, needle) -This function is similar to the 'strstr' function, with the difference being that an integer specifying where the first occurrence begins is returned rather than a string.
  • strrpos(haystack, needle) -An integer specifying where the last occurrence of a character is found within a string is returned by this function.
  • strspn(string1, string2) -This function will return the number of sequential characters at the beginning of a string that match the characters supplied in the second parameter.
  • strcspn(string1, string2) -Rather than providing the number of characters that match the second parameter, this function returns the number of sequential characters that do not match.

    More Programming Basics Articles
    More By Matt Wade


       · comment
       · really goood work ,it covers all the major string functions.also explained with...
       · test'ng
     

  • PROGRAMMING BASICS ARTICLES

    - Loops and PHP Decision Making
    - Operators, Conditionals, and PHP Decision-Ma...
    - PHP Decision-Making
    - Coding
    - Server Statistics
    - Looping in PHP
    - Cookies in PHP
    - Working with text files
    - Beginning Object Oriented Programming in PHP
    - A Tour of Decision Making Structures in PHP
    - PHP Strings Primer
    - PHP Control Structures
    - Intro to Vim
    - Reading Directorys with PHP
    - An Overview of Arrays in PHP





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT