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 ...
- 01-09-2017, 01:20 PM #1
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).
$short_string = “This string has 29 characters”; print(“It does have “ . strlen($short_string) . “ characters”);
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:
- 01-10-2017, 12:14 PM #2
- Join Date
- Sep 2016
Re: Inspecting strings
When we define variables as alphanumeric in COBOL, we often need to evaluate individual characters within the field.