IT Community - Software Programming, Web Development and Technical Support

PHP String Functions With Examples

This is a discussion on PHP String Functions With Examples within the PHP Programming forums, part of the Web Development category; hai i have read PHP string functions. how can use these functions on right place with right functions give me ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-10-2008, 12:56 AM
jegan jegan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 161
jegan is on a distinguished road
Default PHP String Functions With Examples

hai

i have read PHP string functions. how can use these functions on right place with right functions give me some examples


Thanks
__________________
Thanks & Regards,
Jegan CBK
"We will either find a way, or make one!”
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-10-2008, 02:00 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 181
saravanan is on a distinguished road
Default Re: PHP String Functions With Examples

str_split function

The str_split() function splits a string into an array.
to used to check give character comes or not in that input string
PHP Code:
<?
$vInput
="addf";
$vStr=str_split($vInput);
for(
$i=0;$i<count($vStr);$i++)
{
    if(
$vStr[i]=='d')
     {
         
$vA++;
      }
}
echo 
$vA++;
?>

output;
2
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-10-2008, 02:04 AM
jegan jegan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 161
jegan is on a distinguished road
Default Re: PHP String Functions With Examples

what is explode function ?
__________________
Thanks & Regards,
Jegan CBK
"We will either find a way, or make one!”
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-10-2008, 02:08 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 181
saravanan is on a distinguished road
Default Re: PHP String Functions With Examples

The explode() function breaks a string into an array.
example:

PHP Code:
<?php
$str 
"Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?>
output

Array
(
[0] => Hello
[1] => world.
[2] => It's
[3] => a
[4] => beautiful
[5] => day.
)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-10-2008, 02:10 AM
jegan jegan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 161
jegan is on a distinguished road
Default Re: PHP String Functions With Examples

what is implode function?
__________________
Thanks & Regards,
Jegan CBK
"We will either find a way, or make one!”
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-12-2008, 06:42 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 181
saravanan is on a distinguished road
Default Re: PHP String Functions With Examples

The implode() function returns a string from the elements of an array.
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo implode(" ",$arr);
?>

The output of the code above will be:

Hello World! Beautiful Day!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-12-2008, 06:43 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 181
saravanan is on a distinguished road
Default Re: PHP String Functions With Examples

how to find the no's words in a string ?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-12-2008, 06:49 AM
sureshbabu sureshbabu is offline
D-Web Programmer
 
Join Date: Jul 2007
Location: India
Posts: 98
sureshbabu is on a distinguished road
Send a message via AIM to sureshbabu Send a message via MSN to sureshbabu Send a message via Yahoo to sureshbabu Send a message via Skype™ to sureshbabu
Default Re: PHP String Functions With Examples

The count_chars() function returns how many times an ASCII character occurs within a string and returns the information.

Syntax

count_chars(string,mode)

Example 1

In this example we will use count_char() with mode 1 to check the string. Mode 1 will return an array with the ASCII value as key and how
many times it occurred as value (e.g. in the example below, the ASCII value for the letter "l" is 108, and it occurs three times):

<?php
$str = "Hello World!";
print_r(count_chars($str,1));
?>

The output of the code above will be:

Array
(
[32] => 1
[33] => 1
[72] => 1
[87] => 1
[100] => 1
[101] => 1
[108] => 3
[111] => 2
[114] => 1
)
__________________
Thanks
Regards
Sureshbabu Harikrishnan
+91 9884320017
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-05-2008, 11:52 PM
sahara10 sahara10 is offline
D-Web Trainee
 
Join Date: Aug 2008
Posts: 3
sahara10 is on a distinguished road
Default Re: PHP Examples

While the administrators and moderators of this forum will attempt to remove or edit any generally objectionable material as quickly as possible, it is impossible to review every message. Therefore you acknowledge that all posts made to these forums express the views and opinions of the author and not the administrators, moderators or webmaster (except for posts by these people) and hence will not be held liable.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
string functions and manipulations in php Anand PHP Programming 84 12-04-2007 12:17 AM
PHP functions and examples varghese PHP Programming 7 11-19-2007 06:02 AM
HTML and CSS examples varghese HTML, CSS and Javascript Coding Techniques 0 11-09-2007 03:33 AM
Examples in SQL/MYSQL varghese Database Support 0 11-09-2007 03:10 AM
TSL functions used for moving the pointer to that text string in winrunner senthilkannan Testing Tools 0 07-30-2007 02:08 AM


All times are GMT -7. The time now is 02:01 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0