• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

PHP Function strchr() – Alias of strstr()

by admin

The strchr() function is used to find the first appearance of a string inside another string. It is the pseudonym of the strstr() function. This function was introduced in PHP3.

Syntax:

strchr(string $haystack, string $needle, bool $before_needle = false): string|false

For instance:

$record = "Fred,Flintstone,35,Wilma";
$rest = strchr($record, ",");  // $rest is ",Flintstone,35,Wilma"

The variations on strstr() are:

stristr(): Case-insensitive strstr().
strchr(): Alias for strstr().
strrchr(): Find last occurrence of a character in a string.

Filed Under: PHP

Some more articles you might also be interested in …

  1. PHP Function strncasecmp() – Binary safe case-insensitive string comparison of the first n characters
  2. PHP connection_status function – Returns connection status bitfield
  3. PHP function str_replace() – Replace all occurrences of the search string with the replacement string
  4. htaccess Cheatsheet
  5. PHP function str_ireplace() – Case-insensitive version of str_replace()
  6. PHP function stripslashes() – Un-quotes a quoted string
  7. PHP atan function – Arc tangent
  8. PHP decbin function – Decimal to binary
  9. PHP ceil function – Round fractions up
  10. PHP function chunk_split() – Split a string into smaller chunks

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright