programming-examples/php/String/PHP script to get the first word of a sentence.php

5 lines
91 B
PHP
Raw Permalink Normal View History

2019-11-15 12:59:38 +01:00
<?php
$s = 'The quick brown fox';
$arr1 = explode(' ',trim($s));
echo $arr1[0]."\n";
?>