note 107588 modified in function.strstr by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 20:41:46 +0000 |
| Subject: | note 107588 modified in function.strstr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187823@lists.php.net to get a copy of this message | ||
I was in need of getting the first and last part of a string pre 5.3 so I wrote
this: <?php $fir = $first = explode(
" ", $cmd[1] ); unset( $fir[0] ); $end = ltrim(
implode( " ", $fir )
); ?> I needed it split with a "
" but can obviously change for your needs. But with this format your output for the
string: "PHP is the best programming language out
there" Will give you the following
results: <?php $first[0] //
PHP $end // is the best programming language out
there ?> Works really well :)
--was--
I was in need of getting the first and last part of a string pre 5.3 so I wrote this:
<?php
$fir = $first = explode( " ", $cmd[1] );
unset( $fir[0] );
$end = ltrim( implode( " ", $fir ) );
?>
I needed it split with a " " but can obviously change for your needs. But with this format
your output for the string:
"PHP is the best programming language out there"
Will give you the following results:
<?php
$first[0] \\ PHP
$end \\ is the best programming language out there
?>
Works really well :)
http://php.net/manual/en/function.strstr.php