{"id":8593,"date":"2021-08-20T19:47:53","date_gmt":"2021-08-20T16:47:53","guid":{"rendered":"https:\/\/elzero.org\/?p=8593"},"modified":"2022-08-07T07:01:31","modified_gmt":"2022-08-07T04:01:31","slug":"php-problems-solving-find-longest-word-in-string","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/php-problems-solving-find-longest-word-in-string\/","title":{"rendered":"Find Longest Word In a String"},"content":{"rendered":"<h3>\u0627\u0644\u062d\u0644<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-php\">\r\n\/\/ PHP Version 7.4.22 \r\n\r\nfunction longest_word_in($sentence) {\r\n  \/\/ Convert To Array\r\n  $wordsList = explode(\" \", $sentence);\r\n\r\n  \/\/ echo '<pre>';\r\n  \/\/ print_r($wordsList);\r\n  \/\/ echo '<\/pre>';\r\n\r\n  \/\/ Set Longest Word Variable\r\n  $longestWord = '';\r\n  foreach($wordsList as $word) :\r\n    \/\/ Check If Current Word in Loop > The Main Longest Word\r\n    if (strlen($word) > strlen($longestWord)) {\r\n      \/\/ Set The Longest Word === Current Word\r\n      $longestWord = $word;\r\n    }\r\n  endforeach;\r\n  return $longestWord;\r\n}\r\n\r\necho longest_word_in(\"In Programming We Love Elzero Academy Tooooooooooo Much\");\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>Find Longest Word In a String With PHP<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1337],"tags":[],"class_list":["post-8593","post","type-post","status-publish","format-standard","hentry","category-problems-solving"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=8593"}],"version-history":[{"count":4,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8593\/revisions"}],"predecessor-version":[{"id":8629,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8593\/revisions\/8629"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=8593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=8593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=8593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}