Freelancer job part time jobs

HF Social
  • Home
  • Jobs hiring now
  • FAQ
  • Contact

String explode in PHP – php tutorial

February 2, 2011 by Freelance Leave a Comment

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • More
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to email this to a friend (Opens in new window)
  • Click to print (Opens in new window)

Whenever you desire to change a string into small parts then explode is the best used function for you. In case, you want to change a sentence into small particles, then use the command.
For instance; your required sentence is “Hi John, I am just coming here”.
This sentence will be like this:
1. Hi
2. John,
3. I
4. am
5. just
6. coming
7. here.
Now, we can not find the sentence but we can see the scattered particles of it. Now, you have an idea of the work of this function. Here is an example which will make it clearer.
The function of explode:
The function requires a delimiter for make the string to scatter into small pieces. The function explode gives back the real words in the form of an array. All the data in the array is gathered according to the sentence order. We can give the example of a mobile number. We have divided it by using hyphen.

$rawPhoneNumber = "0323-228-7888";

$phoneChunks = explode("-", $rawPhoneNumber);
echo "Real Phone Number = $rawPhoneNumber <br />";
echo "1st part = $phoneChunks[0]<br />";
echo "2nd part = $phoneChunks[1]<br />";
echo "3rd part = $phoneChunks[2]";

Real Phone Number = 0323-228-7888
1st part = 0323
2nd part = 228
3rd part = 7888
How to set a limit in explode function?
In case, you would like to get the number of division done by this explode function then you can think up of one more argument. This argument can make the divided particles into a pattern. It counts the parts. When the parts become equal to the real number then it stops dong its function.

$someWords = "I will give you possible help";

$wordChunks = explode(" ", $someWords);
for($i = 0; $i < count($wordChunks); $i++){
    echo "Piece $i = $wordChunks[$i] <br />";
}

$wordChunksLimited = explode(" ", $someWords, 4);
for($i = 0; $i < count($wordChunksLimited); $i++){
    echo "Limited Piece $i = $wordChunksLimited[$i] <br />";
}

Piece 0 = I
Piece 1 = will
Piece 2 = give
Piece 3 = you
Piece 4 = possible
Piece 5 = help.
Limited Piece 0 = I
Limited Piece 1 = will
Limited Piece 2 = give
Limited Piece 3 = you possible help.
Here, we have divided the sentences into pieces. The limit of characters is four. That is why the last piece has three words in it.

100% Bonus

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • More
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to email this to a friend (Opens in new window)
  • Click to print (Opens in new window)
Implode array in PHP – php tutorial
String position and strops in PHP – php tutorial
Capitalization function of PHP Strings – php tutorial
Functions in PHP
For Loop in PHP – php tutorial
File Read in PHP – php tutorial
While Loop in PHP – php tutorial
Control Structures in PHP language
PHP Operators – php tutorial
Switch Statement in PHP – php tutorial
Function of substr_replace in PHP – php tutorial
Why we use Sessions in PHP – php tutorial
Comments in PHP – php tutorial

Filed Under: PHP

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CAPTCHA
Refresh

*

Earn money as trader

HotForex 50% Bonus

Earn from home ads

Work from home ads

Work from home as instaforex forex trader

instaforex bonus 30%

Freelance categories

  • Earn money as webmaster
    • Advertising
    • Affiliate program
    • Amazon
    • Bidvertiser
    • Blogging
    • Facebook
    • Google Adsense
    • Hosting
    • Komoona
    • LinkedIn
    • Neteller
    • SEO
    • Skrill Moneybookers
    • Twitter
  • Education
    • How to do
    • Job description glossary
    • Wordpress how to do
  • Freelancer advice tips
    • Forex trading from home
      • Affiliate programs
        • 500affiliates
        • Avapartner
        • Etoropartners affiliate program
        • HotForex Affiliate program HFaffiliates
      • Binary options trading
        • Anyoption
        • OptionBit Review
        • TradeRush
        • Ubinary
        • Yesoption
      • Facebook IPO price – buy facebook stock
      • Forex brokers reviews
        • 4XP Review
        • Alpari Russia Review
        • Alpari UK
        • AvaTrade Review
          • AvaFx Review
        • DeltaStock Review
        • Directfx Review
        • DukaScopy Review
        • Easy Forex Review
        • Etoro Review
        • ETX Capital Review
        • Exness
        • Forex.com Review
        • Forex4you
        • ForexYard Review
        • FXCM Review
        • FXDD Review
        • FxOpen Review
        • Fxpro Review
        • HiWayFX review
        • Hotforex Review
        • HY Markets Review
        • IC Markets Forex Review
        • IFC Market
        • IForex Review
        • IG Markets
        • Instaforex Review
        • Ironfx Review
        • Keystock Review
        • LCG review
        • Liteforex broker
        • Marketiva Review
        • Markets.com Review
        • NordFx Review
        • Pepperstone Review
        • Plus500 review
        • Roboforex
        • SwissQuote Bank Review
        • Thinkforex
        • UFX Markets review
        • Windsor Brokers Review
        • XeMarkets Review
        • xForex
        • Xtrade Review
        • Youtrade FX Review
        • Zulutrade Review
    • Freelance glossary
    • Freelance Programming tips
    • Learn about programming
      • C++
      • Linux
      • PHP
      • Ruby on rails
      • SQL
    • Top freelance websites
    • Web Design tips
    • Work from home business
    • Writing tips
  • Freelancer job news
    • Job advice
    • Thinking
    • Worldwide job offers
  • IT news
  • Jobs

Best Forex Brokers Reviews

  • Avafx Review – how to earn in forex market using Avafx Forex Broker
  • Avatrade Review
  • eToro Review
  • Alpari NZ Review
  • InstaForex Review
  • DukaScopy Review – Swiss bank Forex broker
  • Forex.com Review – how to earn money in forex market as trader
  • Ironfx Review
  • FXCM Review
  • FxOpen Review
  • Hotforex Review
  • Markets.com Review
  • UFX Markets Review
  • Zulutrade Review – earn money using free forex signals where forex experts trade for you
  • Exness forex broker Review
  • Fxpro Review
  • LiteForex forex broker review
  • NordFx Review and bonus
  • Roboforex forex broker Review
  • XM.com Review - Xemarkets forex broker review

Navigation

  • Home
  • Jobs hiring now
  • FAQ
  • Contact

Languages

  • Arabic language
  • Bengali language
  • Communiqué de presse
  • China language
  • Pressemitteilung
  • Japanese language
  • Comunicado de imprensa
  • Russian language
  • Presione soltar
  • Turkish
  • Comunicato stampa
  • Hindi language

Recent articles

  • How to earn money as freelancer ?
  • LCG broker Review
  • Forex vs. stocks – Which is a Better for Trading ?
  • Thinkmarkets Review
  • FxPro Review – download FxPro Metatrader – tight spreads
Freelancer job - Copyright 2007
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.