$nums="";//Declare a variable with empty set.$nums.=$number;//concatenate the empty string with the integer $number You can also use$nums=$nums.$number;// this and the expression above do the same thing choose whichever you//like.. This concatenation automatically converts integer to string$nums[0] is now 4,$nums[1] is now 5, etc..$length=strlen($nums);// This is the length of your integer.$target=strlen($nums)-1;// target the last digit in the string; $last_digit=$nums[$target];// This is the value of 5. Last digit in the (now string)
$list="one-two-three";$sep_char="-";// array of all needed items: "one", "two", "three"$arr=explode($sep_char,$list);// array of max two items: "one", "two-three"$arr=explode($sep_char,$list,2);
$stringArray=['Name=xyz','Email=xyz43@gmail.com','Password=xyz@123','Address=xyz University Lucknow'];$loginCredentials=[];foreach($stringArrayas$item){$data=explode('=',$item);if(in_array('Email',$data)||in_array('Password',$data)){$loginCredentials[$data[0]]=$data[1];}}//Output desired arrayprint_r($loginCredentials);