Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 34

Thread: Day 3 - String Operations - Become PHP Expert in 30 days.

  1. #21
    Join Date
    Oct 2003
    Location
    Kochi, Kerala, India
    Posts
    21,389

    Default

    DAY 3 - strlen()

    http://php.flashwebhost.com/vineesh/day3/strlen.php

    Code
    Code:
    <?php
    
    $sentenceOne = 'Hello, I am Vineesh Mohan';
    $sentenceTwo = 'I am working in FlashWebHost.com';
    $sentenceThree = 'FlashWebHost.com provides Domain Registration, Hosting And Web Design Services';
    
    echo $sentenceOne . '<br>';
    echo $sentenceTwo . '<br>';
    echo $sentenceThree . '<br> <br>';
    
    
    echo strlen ($sentenceOne) . '<br>' ;
    echo strlen ($sentenceTwo) . '<br>' ;
    echo strlen ($sentenceThree);
    Another one:

    http://php.flashwebhost.com/vineesh/day3/strlen_1.php

    Code:
    <?php
    
    $name = 'Vineesh Mohan';
    $place = 'Kodamthuruth';
    $city = 'Alappuzha';
    
    
    echo 'I am ' . $name . '<br>' ;
    echo 'My native is ' . $place . '<br>';
    echo $place . 'is located in ' . $city . ' district. <br> <br>'; 
    
     
    echo 'First two lines contain ' . strlen ($name) . ', ' . strlen($place) . ' letters respectively. And the Third line contains ' . strlen('Kodamthuruthis located in Alappuzha district.') . ' letters.' ;
    Last edited by vineesh; 05-10-2014 at 10:36 AM.

  2. #22
    Join Date
    May 2014
    Posts
    21

    Post

    Code:
    <?php
    $company='bizhat';
    $sent=' HEY buddy how are you doing';
    echo 'hey '.ucwords($company.' is cooler THAN ANYTHING.'). strtolower(str_replace('buddy', 'man', $sent));
    
    echo '<br>'.str_replace('HEY','',$sent); // here str_replace is used to delete a word.
    in the last code str_replace is used to delete word.

    http://php.flashwebhost.com/austin/day3.php

  3. #23
    Join Date
    May 2014
    Posts
    21

    Default

    Code:
    <?php$company='bizhat';
    $sent=' HEY buddy how are you doing';
    echo 'hey '.ucwords($company.' is cooler ').strtolower('THAN ANYTHING.').strtolower(str_replace('buddy', 'man', $sent));
    echo '<br>'.str_replace('HEY','',$sent);
    http://php.flashwebhost.com/austin/day3.php

    Please post if you find anymore interesting php string functions!!

  4. #24
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    Day 3 PHP Programming

    http://php.flashwebhost.com/tom/str_replace.php

    Code:
    <?php
    
    
    $movieName = 'Mammootty\'s Blockbustor Movie Drishyam';
    
    
    $movieName = str_replace('Mammootty', 'Mohanlal', $movieName);
    
    
    echo $movieName;

    http://php.flashwebhost.com/tom/str_replace_1.php

    Code:
    <?php
    
    
    $movieName = 'Mohanlal\'s Super Hit Movie Mayamohini';
    
    
    echo str_replace('Mohanlal', 'Dileep', $movieName);

  5. #25
    Join Date
    Oct 2003
    Location
    Kochi, Kerala, India
    Posts
    21,389

    Default

    Convert Text to Upper Case.
    http://php.flashwebhost.com/vineesh/day3/strtoupper.php

    Code
    Code:
    <?php
    
    $name = 'Vineesh Mohan';
    $place = 'Kodamthuruth';
    $city = 'Alappuzha';
    
    
    echo strtoupper($name) . '<br>';
    echo strtoupper($place) . '<br>';
    echo strtoupper($city);
    Convert Text to Lower Case.
    http://php.flashwebhost.com/vineesh/day3/strtolower.php

    Code
    Code:
    <?php
    
    $name = 'Vineesh Mohan';
    $place = 'Kodamthuruth';
    $city = 'Alappuzha';
    
    
    echo strtolower($name) . '<br>';
    echo strtolower($place) . '<br>';
    echo strtolower($city) ;

  6. #26
    Join Date
    Oct 2003
    Location
    Kochi, Kerala, India
    Posts
    21,389

    Default

    Convert First Letter of Words to Upper Case
    http://php.flashwebhost.com/vineesh/day3/ucwords.php

    code
    Code:
    <?php
    
    $color = 'my favourite color is white';
    
    $food = 'my favourite food is biriyani';
    
    echo ucwords($color) . '<br>';
    echo ucwords($food);

  7. #27
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

    http://php.flashwebhost.com/stefin/sentence.php

    Code:
    <?php
    $sentence = 'have a nice day!!' ;
    echo strlen($sentence) ;

  8. #28
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

    http://php.flashwebhost.com/stefin/dragon.php
    Code:
    <?php
    
    
    $myWolf = 'I have a pet shadow wolf';
    
    
    $myWolf = ucwords($myWolf);
    
    
    echo $myWolf;
    
    
    echo '<br>' ;
    
    
    $myDragon = 'I Have A Lightning Dragon';
    
    
    $myDragon = ucwords($myDragon);
    
    
    echo $myDragon;

  9. #29
    Join Date
    May 2014
    Posts
    21

    Default

    Quote Originally Posted by stefin View Post
    http://php.flashwebhost.com/stefin/dragon.php
    Code:
    <?php
    
    
    $myWolf = 'I have a pet shadow wolf';
    
    
    $myWolf = ucwords($myWolf);
    
    
    echo $myWolf;
    
    
    echo '<br>' ;
    
    
    $myDragon = 'I Have A Lightning Dragon';
    
    
    $myDragon = ucwords($myDragon);
    
    
    echo $myDragon;
    Stefin thats a great job for a beginner. You really got some talent!
    And you are learning real fast. Never miss a chapter. and google php to learn extra!

  10. #30
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by Austinwhite View Post
    Stefin thats a great job for a beginner. You really got some talent!
    And you are learning real fast. Never miss a chapter. and google php to learn extra!
    Perfect program. No mistakes, followed variable naming convention and single quote for string rules properly.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

Page 3 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •