1 2 >   Sort: Date

How To Compare Two Strings with strcmp()
How To Compare Two Strings with strcmp()? - PHP Script Tips - PHP Built-in Functions for Strings PHP supports 3 string comparison operators, <, ==, and >, that generates Boolean values. But if you want to get an integer result by comparing two strings, you can the strcmp() function, wh...
2007-04-21, 7590👍, 0💬

How To Convert Strings to Upper or Lower Cases
How To Convert Strings to Upper or Lower Cases? - PHP Script Tips - PHP Built-in Functions for Strings Converting strings to upper or lower cases are easy. Just use strtoupper() or strtolower() functions. Here is a PHP script on how to use them: <?php $string = "PHP string functions are easy ...
2007-04-21, 5520👍, 0💬

How To Convert Strings in Hex Format
How To Convert Strings in Hex Format? - PHP Script Tips - PHP Built-in Functions for Strings If you want convert a string into hex format, you can use the bin2hex() function. Here is a PHP script on how to use bin2hex(): <?php $string = "Hello\tworld!\n"; print($string."\n"); print(bin2hex($s...
2007-04-21, 5307👍, 0💬

How To Split a String into Pieces
How To Split a String into Pieces? - PHP Script Tips - PHP Built-in Functions for Strings There are two functions you can use to split a string into pieces: explode(substring, string) - Splitting a string based on a substring. Faster than split(). split(pattern, string) - Splitting a string based on...
2007-04-21, 5300👍, 0💬

How To Convert the First Character to Upper Case
How To Convert the First Character to Upper Case? - PHP Script Tips - PHP Built-in Functions for Strings If you are processing an article, you may want to capitalize the first character of a sentence by using the ucfirst() function. You may also want to capitalize the first character of every words ...
2007-04-21, 5278👍, 0💬

How To Remove White Spaces from the Beginning and/or the End of a String
How To Remove White Spaces from the Beginning and/or the End of a String? - PHP Script Tips - PHP Built-in Functions for Strings There are 4 PHP functions you can use remove white space characters from the beginning and/or the end of a string: trim() - Remove white space characters from the beginnin...
2007-04-22, 5227👍, 0💬

How to Find a Substring from a Given String
How to Find a Substring from a Given String? - PHP Script Tips - PHP Built-in Functions for Strings To find a substring in a given string, you can use the strpos() function. If you call strpos($haystack, $needle), it will try to find the position of the first occurrence of the $needle string in the ...
2007-04-21, 5120👍, 0💬

How To Convert a Character to an ASCII Value
How To Convert a Character to an ASCII Value? - PHP Script Tips - PHP Built-in Functions for Strings If you want to convert characters to ASCII values, you can use the ord() function, which takes the first charcter of the specified string, and returns its ASCII value in decimal format. ord() complem...
2007-04-21, 5095👍, 0💬

How To Remove Leading and Trailing Spaces from User Input Values
How To Remove Leading and Trailing Spaces from User Input Values? - PHP Script Tips - PHP Built-in Functions for Strings If you are taking input values from users with a Web form, users may enter extra spaces at the beginning and/or the end of the input values. You should always use the trim() funct...
2007-04-22, 5015👍, 0💬

What Is the Best Way to Test the strpos() Return Value
What Is the Best Way to Test the strpos() Return Value? - PHP Script Tips - PHP Built-in Functions for Strings Because strpos() could two types of values, Integer and Boolean, you need to be careful about testing the return value. The best way is to use the "Identical(===)" operator. Do not use the ...
2007-04-21, 4982👍, 0💬

How To Replace a Group of Characters by Another Group
How To Replace a Group of Characters by Another Group? - PHP Script Tips - PHP Built-in Functions for Strings While processing a string, you may want to replace a group of special characters with some other characters. For example, if you don't want to show user's email addresses in the original for...
2007-04-20, 4945👍, 0💬

How To Reformat a Paragraph of Text
How To Reformat a Paragraph of Text? - PHP Script Tips - PHP Built-in Functions for Strings You can wordwrap() reformat a paragraph of text by wrapping lines with a fixed length. Here is a PHP script on how to use wordwrap(): <?php $string = "TRADING ON MARGIN POSES ADDITIONAL RISKS AND IS NO...
2007-04-21, 4918👍, 0💬

How To Convert Strings to Numbers
How To Convert Strings to Numbers? - PHP Script Tips - Understanding String Literals and Operations In a numeric context, PHP will automatically convert any string to a numeric value. Strings will be converted into two types of numeric values, double floating number and integer, based on the followi...
2007-04-20, 4871👍, 0💬

How To Convert Numbers to Strings
How To Convert Numbers to Strings? - PHP Script Tips - Understanding String Literals and Operations In a string context, PHP will automatically convert any numeric value to a string. Here is a PHP script examples: <?php print(-1.3e3); print("\n"); print(strlen(-1.3e3)); print("\n"); print("Pr...
2007-04-20, 4861👍, 0💬

How To Take a Substring from a Given String
How To Take a Substring from a Given String? - PHP Script Tips - PHP Built-in Functions for Strings If you know the position of a substring in a given string, you can take the substring out by the substr() function. Here is a PHP script on how to use substr(): <?php $string = "beginning"; pri...
2007-04-21, 4848👍, 0💬

How To Replace a Substring in a Given String
How To Replace a Substring in a Given String? - PHP Script Tips - PHP Built-in Functions for Strings If you know the position of a substring in a given string, you can replace that substring by another string by using the substr_replace() function. Here is a PHP script on how to use substr_replace()...
2007-04-21, 4823👍, 0💬

How To Generate a Character from an ASCII Value
How To Generate a Character from an ASCII Value? - PHP Script Tips - PHP Built-in Functions for Strings If you want to generate characters from ASCII values, you can use the chr() function. chr() takes the ASCII value in decimal format and returns the character represented by the ASCII value. chr() ...
2007-04-21, 4822👍, 0💬

How To Remove the New Line Character from the End of a Text Line
How To Remove the New Line Character from the End of a Text Line? - PHP Script Tips - PHP Built-in Functions for Strings If you are using fgets() to read a line from a text file, you may want to use the chop() function to remove the new line character from the end of the line as shown in this PHP sc...
2007-04-22, 4814👍, 0💬

How To Concatenate Two Strings Together
How To Concatenate Two Strings Together? - PHP Script Tips - Understanding String Literals and Operations You can use the string concatenation operator (.) to join two strings into one. Here is a PHP script example of string concatenation: <?php echo 'Hello ' . "world!\n"; ?> This scri...
2007-04-20, 4807👍, 0💬

How To Access a Specific Character in a String
How To Access a Specific Character in a String? - PHP Script Tips - Understanding String Literals and Operations Any character in a string can be accessed by a special string element expression: $string{index} - The index is the position of the character counted from left and starting from 0. Here i...
2007-04-20, 4749👍, 0💬

How To Join Multiple Strings into a Single String
How To Join Multiple Strings into a Single String? - PHP Script Tips - PHP Built-in Functions for Strings If you multiple strings stored in an array, you can join them together into a single string with a given delimiter by using the implode() function. Here is a PHP script on how to use implode(): ...
2007-04-21, 4732👍, 0💬

What Are the Special Characters You Need to Escape in Double-Quoted Stings
What Are the Special Characters You Need to Escape in Double-Quoted Stings? - PHP Script Tips - Understanding String Literals and Operations There are two special characters you need to escape in a double-quote string: the double quote (") and the back slash (\). Here is a PHP script example of doub...
2007-04-20, 4728👍, 0💬

How To Get the Number of Characters in a String
How To Get the Number of Characters in a String? - PHP Script Tips - PHP Built-in Functions for Strings You can use the "strlen()" function to get the number of characters in a string. Here is a PHP script example of strlen(): <?php print(strlen('It\'s Friday!')); ?> This script will p...
2007-04-22, 4717👍, 0💬

Can You Specify the "new line" Character in Single-Quoted Strings
Can You Specify the "new line" Character in Single-Quoted Strings? - PHP Script Tips - Understanding String Literals and Operations You can not specify the "new line" character in a single-quoted string. If you don't believe, try this script: <?php echo '\n will not work in single quoted stri...
2007-04-20, 4662👍, 0💬

1 2 >   Sort: Date