Get First text from a string after (-) dash using php

Get First text from a string after (-) dash using php

Get first content form multiple dash (-) in a string by strtok  using php

 

$data = "123-String-home-4";    
$whatIWant = strtok($data, '-');   
echo $whatIWant;

Here the result is : 123. get the fist string.

$data = "123_String_home_4_5_6"; 
$arr = explode("_", $data,4);
echo $first = $arr[0]."<br>";

Here the result is 123.

 

explode("_", $data,4);

it means, the full string is divided in 4 parts
Array
(
    [0] => 123
    [1] => String
    [2] => home
    [3] => 4_5_6
);
echo $arr[0]; is print the first index of this string.
if $arr[1] then the result is String.

dini sohbet Texture R57 shell indir Türk instagram takipçi satın al