Results 1 to 6 of 6

Thread: Finding php string length

  1. #1
    Join Date
    Apr 2008
    Posts
    242

    Finding php string length

    Hello experts !

    I am developing a school competition application which contains some little functionality but I am getting some problem regarding string manipulation,I can perform the desired operations on number values.

    But,teacher told me just create a logic which accepts the name of the user and present the name of user according to position of letter which the use requires
    For example -
    Enter user name : Alena
    Enter the Character position to view : 2

    Output :ena

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Finding php string length

    hey dude !

    Its very simple to understand.You have to use your little bit of mind and use the provided utility of the PHP programming.PHP programming contains a rich set of function for different purposes.

    To do this,You need to find out the functionality of different function which is related to string.you have to find out the length of the whole string which is entered by the user and keep the value of position into another variable and put the value in the function which divides the string according to the position.

    Now assign this divided value in another character variable and pass it with echo statement to print the result.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    PHP - String Creation

    Before implementation of the string you need to create it in your program. A string is used within a function or being stored in a variable which would be present and declared in the program code.

    I am going create the string in which the first being stored into a variable and the just below described statement will take this string and print on the screen to display the output.

    Code:
    $Cr_string = "Hello guys !Getting ....";
    echo "Hello guys !Getting ...."; // first way to display the output directly...
    echo $Cr_string;              // Second way the string is going to print after assignment of value in variable.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    String Creation using Single Quotes

    String Creation using Single Quotes

    Earlier,We are aware of creation of strings using double-quotes but you can create the string using single-quotes, But you need to care about some characters which can create some problem .

    For example,if you created a string in which you got a single apostrophe then you have to use some defined symbol to display the desired output.

    Code:
    $Str_var = 'Its the magic of Programming .....';
    echo 'Its the magic of Programming .....';
    echo $Str_var;
    If you include some apostrophe then you need to use the escape (\) like

    Code:
    echo 'It\'s the magic of Programming .....';

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    PHP String length counting by strlen

    Using STRLEN functions :

    The strlen function is used to find the length of the string variable.If the user enter the value as a string then you have define a variable which can contain a long size of string variable.

    The value which is entered by the use,you need to store it in the defined variable and pass the variable to the function named STRLEN.

    The example would be as follows :

    Code:
    <?
    
    $Str_var="It's mine.....";
    
    echo "Length of the string = ".strlen($Str_var);
    
    ?>

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    String manipulated functions

    There are so many functions are provided to make operation on strings.I am going to show you the list of relative functions which can help you to find your solution which you have currently.

    Preator suggested you well,just go through the suggested procedure and use appropriate function which can be valuable for you .

    The function are listed here -

    Substr_count()
    Strlen()
    Substr_count ()
    Strcmp()
    Str_pad()

    These are the functions which can help you a lot to find the way.

Similar Threads

  1. What is the maximum length of URL
    By Lawford in forum Software Development
    Replies: 5
    Last Post: 18-02-2010, 04:12 AM
  2. Get String Length with Javascript
    By klite in forum Software Development
    Replies: 3
    Last Post: 31-10-2009, 11:39 AM
  3. How to Manipulate String using PHP String Functions
    By ComPaCt in forum Software Development
    Replies: 3
    Last Post: 21-09-2009, 09:07 AM
  4. Length of a string displayable in C
    By Berlin Baby in forum Software Development
    Replies: 3
    Last Post: 10-01-2009, 07:06 PM
  5. max length filename
    By John A Grandy in forum Windows Server Help
    Replies: 6
    Last Post: 23-10-2008, 11:00 PM

Tags for this Thread

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
  •  
Page generated in 1,713,554,129.35702 seconds with 16 queries