IT Community - Software Programming, Web Development and Technical Support

string functions and manipulations in php

This is a discussion on string functions and manipulations in php within the PHP Programming forums, part of the Web Development category; Let us discuss about strlen() strlen - It is used to return the length of the string that is passed as ...


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

Register FAQ Members List Calendar Mark Forums Read
  #81 (permalink)  
Old 11-18-2007, 10:22 PM
vims vims is offline
D-Web Programmer
 
Join Date: Oct 2007
Posts: 67
vims is on a distinguished road
Wink Re: string functions and manipulations in php

Let us discuss about strlen()

strlen - It is used to return the length of the string that is passed as an argument.

Syntax:

strlen(stringname);

Example:
Code:
$vString="Discuss web"; 
echo strlen($vString);

Output:
11
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #82 (permalink)  
Old 11-30-2007, 03:10 PM
venkat_charya venkat_charya is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 118
venkat_charya is on a distinguished road
Thumbs up Re: string functions and manipulations in php

str_word_count()

The str_word_count() function counts the number of words in a string.

Syntax
str_word_count(string,return,char)

Parameters are
string = Specifies the string to check and it is Required field.
return = Specifies the return value of the str_word_count() function and Optional.

Possible values:
0 - Default. Returns the number of words found
1 - Returns an array with the words from the string
2 - Returns an array where the key is the position of the word in the string, and value is the actual word

char = Specifies special characters to be considered as words and it is Optional field.

Note: This parameter was added in PHP 5.1

PHP Code:
<?php
echo str_word_count("Hello world!");
?>
Output
2

Thanks
__________________
K K Venkata Charya
Success is easy to get but difficult to retain
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #83 (permalink)  
Old 11-30-2007, 03:23 PM
venkat_charya venkat_charya is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 118
venkat_charya is on a distinguished road
Thumbs up Re: string functions and manipulations in php

strtok()

The strtok() function splits a string into smaller strings.

Syntax
strtok(string,split)

Parameters
string = Specifies the string to split and it is Required field.
split = Specifies one or more split characters and it is Required field.

strtok() splits a string (str) into smaller strings (tokens), with each token being delimited by any character from token. That is, if you have a string like "This is an example string" you could tokenize this string into its individual words by using the space character as the token.

PHP Code:
<?php
$first_token  
strtok('/something''/');
$second_token strtok('/');
var_dump($first_token$second_token);
?>
Output:
string(0) ""
string(9) "something"

Thanks
__________________
K K Venkata Charya
Success is easy to get but difficult to retain
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #84 (permalink)  
Old 12-03-2007, 06:59 AM
Senthilkumar Senthilkumar is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 93
Senthilkumar is on a distinguished road
Default Re: string functions and manipulations in php

Hi KK

Is any string function available in PHP to decode or encode the HTML contents?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #85 (permalink)  
Old 12-04-2007, 01:17 AM
Explizite Explizite is offline
D-Web Trainee
 
Join Date: Dec 2007
Posts: 28
Explizite is on a distinguished road
Default Re: string functions and manipulations in php

Why do you need to encode HTML contents?
Maybe you'd like to encode a string, or a number of strings maybe?
If so, there are thousand of algorythms to achieve this.
Try PHP: Manual Quick Reference
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
Compare a string with String Array. oxygen C# Programming 5 12-28-2007 11:18 PM
What is diffrenece between string.compare and string.compareordinal shaalini ASP and ASP.NET Programming 3 12-28-2007 10:46 PM
What are Virtual Functions? How to implement virtual functions in "C"? Sabari C and C++ Programming 4 09-10-2007 11:35 PM
TSL functions used for moving the pointer to that text string in winrunner senthilkannan Testing Tools 0 07-30-2007 03:08 AM
How to split a string by using a string usually in the c# dotnet... Archer C# Programming 1 07-25-2007 03:26 AM


All times are GMT -7. The time now is 06:20 PM.


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

SEO by vBSEO 3.0.0