Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

strrchr(3) [php man page]

STRRCHR(3)								 1								STRRCHR(3)

strrchr - Find the last occurrence of a character in a string

SYNOPSIS
string strrchr (string $haystack, mixed $needle) DESCRIPTION
This function returns the portion of $haystack which starts at the last occurrence of $needle and goes until the end of $haystack. PARAMETERS
o $haystack - The string to search in o $needle - If $needle contains more than one character, only the first is used. This behavior is different from that of strstr(3). If $needle is not a string, it is converted to an integer and applied as the ordinal value of a character. RETURN VALUES
This function returns the portion of string, or FALSE if $needle is not found. CHANGELOG
+--------+------------------------------------+ |Version | | | | | | | Description | | | | +--------+------------------------------------+ | 4.3.0 | | | | | | | This function is now binary safe. | | | | +--------+------------------------------------+ EXAMPLES
Example #1 strrchr(3) example <?php // get last directory in $PATH $dir = substr(strrchr($PATH, ":"), 1); // get everything after last newline $text = "Line 1 Line 2 Line 3"; $last = substr(strrchr($text, 10), 1 ); ?> NOTES
Note This function is binary-safe. SEE ALSO
strstr(3), strrpos(3). PHP Documentation Group STRRCHR(3)

Check Out this Related Man Page

STRISTR(3)								 1								STRISTR(3)

stristr - Case-insensitivestrstr(3)

SYNOPSIS
string stristr (string $haystack, mixed $needle, [bool $before_needle = false]) DESCRIPTION
Returns all of $haystack starting from and including the first occurrence of $needle to the end. PARAMETERS
o $haystack - The string to search in o $needle - If $needle is not a string, it is converted to an integer and applied as the ordinal value of a character. o $before_needle - If TRUE, stristr(3) returns the part of the $haystack before the first occurrence of the $needle (excluding needle). $needle and $haystack are examined in a case-insensitive manner. RETURN VALUES
Returns the matched substring. If $needle is not found, returns FALSE. CHANGELOG
+--------+-----------------------------------------------+ |Version | | | | | | | Description | | | | +--------+-----------------------------------------------+ | 5.3.0 | | | | | | | Added the optional parameter $before_needle. | | | | | 4.3.0 | | | | | | | stristr(3) was made binary safe. | | | | +--------+-----------------------------------------------+ EXAMPLES
Example #1 stristr(3) example <?php $email = 'USER@EXAMPLE.com'; echo stristr($email, 'e'); // outputs ER@EXAMPLE.com echo stristr($email, 'e', true); // As of PHP 5.3.0, outputs US ?> Example #2 Testing if a string is found or not <?php $string = 'Hello World!'; if(stristr($string, 'earth') === FALSE) { echo '"earth" not found in string'; } // outputs: "earth" not found in string ?> Example #3 Using a non "string" needle <?php $string = 'APPLE'; echo stristr($string, 97); // 97 = lowercase a // outputs: APPLE ?> NOTES
Note This function is binary-safe. SEE ALSO
strstr(3), strrchr(3), stripos(3), strpbrk(3), preg_match(3). PHP Documentation Group STRISTR(3)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove blank lines

¿How can i remove blank lines between all lines in a long text file? Example WrongFile.txt : Line 1 Line 2 Line 3 CorrectFile.txt : Line 1 Line 2 Line 3 Thanks in advance :confused: (4 Replies)
Discussion started by: osymad
4 Replies

2. Shell Programming and Scripting

Perl conversion & perldoc question

Working my way through a perl book and can't find this; You can convert from binary to ordinal numbers using 0b in front of the binary value but how do you go the other way, from ordinal to binary? Is there a function for this? On Perldoc, is there a document that gives all of the available... (2 Replies)
Discussion started by: thumper
2 Replies

3. Shell Programming and Scripting

sed help

hi i can't convert a string to a new line character via this command: sed -e "s/<string>/\n/g" source > target all it does is change <string> to n. is there anything wrong? (7 Replies)
Discussion started by: cdrk823
7 Replies

4. Shell Programming and Scripting

Remove Line that contains specific string

I am looking for a way to remove any line in a text file that contains the string "Mac address". I guess you would grep and sed, but I am not sure how to do this. Thanks for you help. (3 Replies)
Discussion started by: CBarraford
3 Replies

5. Shell Programming and Scripting

substr() limitations in "AWK" program..!!!

Is there any limitation for the function substr() Iam trying to assign some 11 digit number value to variable. And printing the variable. This is printing invalid values. cur_val=substr($0,36,11); printf "Current Value is: %d\n",cur_val I tried till 9 digits length, it was working fine. If... (6 Replies)
Discussion started by: lokiman
6 Replies

6. Shell Programming and Scripting

get substr?

Hi, I have a long string like, aabab|bcbcbcbbc|defgh|paswd123 dedededede|efef|ghijklmn|paswd234 ghghghghgh|ijijii|klllkkk|paswd345 lmlmlmmm|nononononn|opopopopp|paswd456 This string is devided into one space between substrings. This substrings are, aabab|bcbcbcbbc|defgh|paswd123... (6 Replies)
Discussion started by: syamkp
6 Replies

7. Shell Programming and Scripting

using awk to extract text between two constant strings

Hi, I have a file from which i need to extract data between two constant strings. The data looks like this : Line 1 SUN> read db @cmpd unit 60 Line 2 Parameter: CMPD -> "C00071" Line 3 Line 4 SUN> generate Line 5 tabint>ERROR: (Variable data) The data i need to extract is... (11 Replies)
Discussion started by: mjoshi
11 Replies

8. Shell Programming and Scripting

Grep multiple lines from a file

Hi, I would like to ask if there is any method to grep a chuck of lines based on the latest file in a directory. E.g Latest file in the directory: Line 1: 532243 Line 2: 123456 Line 3: 334566 Line 4: 44567545 I wanted to grep all the line after line 2 i.e. Line 3 and line 4 and... (5 Replies)
Discussion started by: dwgi32
5 Replies

9. Shell Programming and Scripting

Activate all Linux services script

Now i'm up to making a script from which you could activate all Linux services without being an expert. It's gonna be a powerful tool, I'll look forward to make it able to change the port which the service is assigned to. But I need some help, post some script to activate services and I'll fusion... (8 Replies)
Discussion started by: Dax01
8 Replies

10. Shell Programming and Scripting

Need help for Cut Command

Hi All, Greetings.. I am having a Line of 1600 characters in which each specifi fields have some values. For example 1-5 Firstname 6-8 Age and so on.. I am using `expr substr $line 100,7` to get values from the line and store in seperate variables.. The file contains 70000 lines. It is taking 3... (8 Replies)
Discussion started by: dinesh1985
8 Replies

11. Shell Programming and Scripting

File parsing in Unix

I have got a large file with content as below. LOCATION A B C 1 Line 3 Line 4 *Line 8 **Line 9 TAG END LOCATION A B" C 3 Line 33 Line 34 (4 Replies)
Discussion started by: rinku11
4 Replies

12. Shell Programming and Scripting

Faster Line by Line String/Date Comparison of 2 Files

Hello, I was wondering if anyone knows a faster way to search and compare strings and dates from 2 files? I'm currently using "for loop" but seems sluggish as i have to cycle through 10 directories with 10 files each containing thousands of lines. Given: -10 directories -10 files... (4 Replies)
Discussion started by: agentgrecko
4 Replies

13. Shell Programming and Scripting

Is it possible to index substr from right to left?

Hello, all Suppose I have a string "0123456789", if i want to get the substr "56", I know I can use following method: $ string="0123456789" $ echo ${string:5:2} 56 I am wondering if there is some command like: $ echo ${string:6:-2} which can also get the same output "56"? (3 Replies)
Discussion started by: littlewenwen
3 Replies

14. UNIX for Dummies Questions & Answers

Need help in Shell scripting...

Hi, how to take only a portion of a string...? say I search for a character in a string, and I want the content that starts after the character that I search for. Thanks, Qaddaffi.S (3 Replies)
Discussion started by: Qaddaffi
3 Replies

15. Shell Programming and Scripting

Perl substr or similar help

I have a large string containing about 17,500 characters and I would like to obtain the value for token. token only appears in the entire string once and is towards the end of the string at the 17,200 area but that could change. Using perl can someone assist me with obtaining the value which in... (10 Replies)
Discussion started by: azdps
10 Replies