PHP: If String[Index] is in Array, PHP: String from String[1] to String[last] -


is there php call in_str?

…something similar in_array..

am using if-else take each word (string) in array of strings (from form-input-text) see if start index [0] equal single character string in array..

also, how 1 @ string string[1] string[last]?

(these 2 questions highlighted in code using format: **code**)

      if(isset($_post['radiobuttonname']) &&       $_post['radiobuttonname'] == 'avalue') {         $stringsarray = array($_post['forminputtext']);         $vowels = array("a", "e", "i", "o", "u", "a", "e", "i", "o", "u");          foreach ($stringsarray $stringsarraystring)           {             if (**in_str**($stringsarraystring[0], $vowels)) {               echo $stringsarraystring . "aword" . "<&nbsp;>";             }             else {               echo "**$stringsarraystring[1] $stringsarraystring[last]**" . "$stringsarraystring[0]" . "aword" . "<&nbsp;>";             }           }       } 

you can use strpos check if letter in string, search array you'll need use foreach...

    foreach($vowels $vowel)     {         $firstletterisavowel = (strpos($stringsarraystring, $vowel) === 0 ? true : false);     }          if ($firstletterisavowel)) {           echo $stringsarraystring . "aword" . "<&nbsp;>";         }         else {           echo "**".substr($stringsarraystring, 1) . "$stringsarraystring[0]" . "aword" . "<&nbsp;>";         } 

note use of === instead of == strpos returns false if not found, , 0 == false. did because question, i'd rather check if $stringarraystring[0] vowel this...

    in_array ( $stringarraystring[0] , $vowels) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -