Results 1 to 2 of 2

Inspecting strings

This is a discussion on Inspecting strings within the Programming forums, part of the Web Designing & Development category; What kinds of questions can you ask strings? First on the list is how long the string is, using the ...

  1. #1
    Senior Member chinmay.sahoo's Avatar
    Join Date
    Dec 2013
    Location
    Banglore
    Posts
    253

    Thumbs up Inspecting strings

    What kinds of questions can you ask strings? First on the list is how long the string is, using the strlen() function (the name is short for string length).

    Code:
    $short_string = “This string has 29 characters”;
    print(“It does have “ . strlen($short_string) .
    “ characters”);
    This code gives the following output:

    It does have 29 characters


    Knowing the string’s length is particularly useful in form validation or for situations in which we’d like to loop through a string character by character. A useless but illustrative example, using the preceding example string, is:

  2. #2
    Junior Member
    Join Date
    Sep 2016
    Posts
    24

    Default Re: Inspecting strings

    When we define variables as alphanumeric in COBOL, we often need to evaluate individual characters within the field.