--- warning: This file is auto generated by `yarn web:inject`, do not edit by hand examples: - strchr('Kevin van Zonneveld', 'van') - strchr('Kevin van Zonneveld', 'van', true) returns: - '''van Zonneveld''' - '''Kevin ''' dependencies: - php/strings/strstr authors: original by: - Philip Peterson notes: [] parityVerified: - PHP 8.3 isTypescript: true type: function layout: function title: PHP's strchr in TypeScript description: >- Here's what our current TypeScript equivalent to PHP's strchr looks like. function: strchr category: strings language: php permalink: php/strings/strchr/ alias: - /functions/php/strchr/ - /functions/strings/strchr/ - /php/strchr/ - /functions/strchr/ ---
{% codeblock lang:typescript %}import { strstr } from '../strings/strstr.ts' export function strchr(haystack: string, needle: string, bool?: boolean): string | false { // discuss at: https://locutus.io/php/strchr/ // parity verified: PHP 8.3 // original by: Philip Peterson // example 1: strchr('Kevin van Zonneveld', 'van') // returns 1: 'van Zonneveld' // example 2: strchr('Kevin van Zonneveld', 'van', true) // returns 2: 'Kevin ' return strstr(haystack, needle, bool) } {% endcodeblock %}