Extract data from string before a special character
$text = "this_is_a_sample_text";

$data = strstr($text, '_', true);

//result will be "this"