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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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 cos function – Cosine
  2. PHP addslashes function – Quote string with slashes
  3. PHP function strcasecmp() – Binary safe case-insensitive string comparison
  4. PHP Function str_word_count() – Return information about words used in a string
  5. PHP connection_status function – Returns connection status bitfield
  6. PHP function str_ireplace() – Case-insensitive version of str_replace()
  7. PHP function bin2hex – Convert binary data into hexadecimal representation
  8. PHP ceil function – Round fractions up
  9. PHP function acos – Arc cosine
  10. PHP function strlen() – Get string length

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright