{"id":26928,"date":"2024-03-16T07:36:02","date_gmt":"2024-03-16T07:36:02","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/"},"modified":"2024-03-22T09:47:01","modified_gmt":"2024-03-22T09:47:01","slug":"what-is-the-usage-of-the-php-strstr-function","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/","title":{"rendered":"What is the usage of the php strstr function?"},"content":{"rendered":"<p>The PHP strstr function is used to search for a specified string within a string, and returns the portion of the string starting from the specified string to the end of the string.<\/p>\n<p>Here is how to use the function:<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-title function_ invoke__\">strstr<\/span>(<span class=\"hljs-keyword\">string<\/span> <span class=\"hljs-variable\">$haystack<\/span>, <span class=\"hljs-keyword\">mixed<\/span> <span class=\"hljs-variable\">$needle<\/span>, <span class=\"hljs-keyword\">bool<\/span> <span class=\"hljs-variable\">$before_needle<\/span> = <span class=\"hljs-literal\">false<\/span>): <span class=\"hljs-keyword\">string<\/span>|<span class=\"hljs-literal\">false<\/span>\r\n<\/code><\/pre>\n<p>Explanation of parameters:<\/p>\n<ol>\n<li>haystack: the string to search within.<\/li>\n<li>needle: the string to be searched for.<\/li>\n<li>It is an optional parameter that specifies whether to return the portion before the needle. By default, it is set to false, which returns the portion starting from the needle to the end of the string.<\/li>\n<li>Return Value: If the needle is found, return the part of the string from the needle to the end; if not found, return false.<\/li>\n<\/ol>\n<p>Original: \u6211\u4eca\u5929\u6709\u5f88\u591a\u4e8b\u60c5\u8981\u505a\uff0c\u6240\u4ee5\u53ef\u80fd\u4f1a\u5f88\u5fd9\u3002<br \/>\nParaphrased: I have a lot of things to do today, so I might be very busy.<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-variable\">$str<\/span> = <span class=\"hljs-string\">'Hello, world!'<\/span>;\r\n<span class=\"hljs-variable\">$part<\/span> = <span class=\"hljs-title function_ invoke__\">strstr<\/span>(<span class=\"hljs-variable\">$str<\/span>, <span class=\"hljs-string\">'world'<\/span>);\r\n<span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-variable\">$part<\/span>; <span class=\"hljs-comment\">\/\/ \u8f93\u51fa\uff1aworld!<\/span>\r\n\r\n<span class=\"hljs-variable\">$part2<\/span> = <span class=\"hljs-title function_ invoke__\">strstr<\/span>(<span class=\"hljs-variable\">$str<\/span>, <span class=\"hljs-string\">'world'<\/span>, <span class=\"hljs-literal\">true<\/span>);\r\n<span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-variable\">$part2<\/span>; <span class=\"hljs-comment\">\/\/ \u8f93\u51fa\uff1aHello, <\/span>\r\n<\/code><\/pre>\n<p>In the above example, strstr($str, &#8216;world&#8217;) will find the first occurrence of &#8216;world&#8217; in the string and return the part starting from &#8216;world&#8217; to the end of the string. strstr($str, &#8216;world&#8217;, true) will return the part before &#8216;world&#8217;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PHP strstr function is used to search for a specified string within a string, and returns the portion of the string starting from the specified string to the end of the string. Here is how to use the function: strstr(string $haystack, mixed $needle, bool $before_needle = false): string|false Explanation of parameters: haystack: the string [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-26928","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is the usage of the php strstr function? - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is the usage of the php strstr function?\" \/>\n<meta property=\"og:description\" content=\"The PHP strstr function is used to search for a specified string within a string, and returns the portion of the string starting from the specified string to the end of the string. Here is how to use the function: strstr(string $haystack, mixed $needle, bool $before_needle = false): string|false Explanation of parameters: haystack: the string [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-16T07:36:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-22T09:47:01+00:00\" \/>\n<meta name=\"author\" content=\"Ava Mitchell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ava Mitchell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/\"},\"author\":{\"name\":\"Ava Mitchell\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/a3e2658c2cb9fb2be95ae0a8861f4a64\"},\"headline\":\"What is the usage of the php strstr function?\",\"datePublished\":\"2024-03-16T07:36:02+00:00\",\"dateModified\":\"2024-03-22T09:47:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/\"},\"wordCount\":182,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/\",\"name\":\"What is the usage of the php strstr function? - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2024-03-16T07:36:02+00:00\",\"dateModified\":\"2024-03-22T09:47:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is the usage of the php strstr function?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/a3e2658c2cb9fb2be95ae0a8861f4a64\",\"name\":\"Ava Mitchell\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/15c63cd0564b4a2e07d611bcdffa296f6ea80e8db07c3091f43a84010514899d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/15c63cd0564b4a2e07d611bcdffa296f6ea80e8db07c3091f43a84010514899d?s=96&d=mm&r=g\",\"caption\":\"Ava Mitchell\"},\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/avamitchell\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"What is the usage of the php strstr function? - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/","og_locale":"en_US","og_type":"article","og_title":"What is the usage of the php strstr function?","og_description":"The PHP strstr function is used to search for a specified string within a string, and returns the portion of the string starting from the specified string to the end of the string. Here is how to use the function: strstr(string $haystack, mixed $needle, bool $before_needle = false): string|false Explanation of parameters: haystack: the string [&hellip;]","og_url":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2024-03-16T07:36:02+00:00","article_modified_time":"2024-03-22T09:47:01+00:00","author":"Ava Mitchell","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Ava Mitchell","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/"},"author":{"name":"Ava Mitchell","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/a3e2658c2cb9fb2be95ae0a8861f4a64"},"headline":"What is the usage of the php strstr function?","datePublished":"2024-03-16T07:36:02+00:00","dateModified":"2024-03-22T09:47:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/"},"wordCount":182,"commentCount":0,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/","url":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/","name":"What is the usage of the php strstr function? - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2024-03-16T07:36:02+00:00","dateModified":"2024-03-22T09:47:01+00:00","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-php-strstr-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"What is the usage of the php strstr function?"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/a3e2658c2cb9fb2be95ae0a8861f4a64","name":"Ava Mitchell","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/15c63cd0564b4a2e07d611bcdffa296f6ea80e8db07c3091f43a84010514899d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/15c63cd0564b4a2e07d611bcdffa296f6ea80e8db07c3091f43a84010514899d?s=96&d=mm&r=g","caption":"Ava Mitchell"},"url":"https:\/\/www.silicloud.com\/blog\/author\/avamitchell\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/26928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=26928"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/26928\/revisions"}],"predecessor-version":[{"id":61125,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/26928\/revisions\/61125"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=26928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=26928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=26928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}