note 107588 added to function.strstr
| From: | peteratoldsdotco | Date: | Mon, 20 Feb 2012 10:16:51 +0000 |
| Subject: | note 107588 added to function.strstr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186233@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 :)
----
Server IP: 212.124.37.9
Probable Submitter: 216.51.62.165
----
Manual Page -- http://www.php.net/manual/en/function.strstr.php
Edit -- https://master.php.net/note/edit/107588
Del: integrated -- https://master.php.net/note/delete/107588/integrated
Del: useless -- https://master.php.net/note/delete/107588/useless
Del: bad code -- https://master.php.net/note/delete/107588/bad+code
Del: spam -- https://master.php.net/note/delete/107588/spam
Del: non-english -- https://master.php.net/note/delete/107588/non-english
Del: in docs -- https://master.php.net/note/delete/107588/in+docs
Del: other reasons-- https://master.php.net/note/delete/107588
Reject -- https://master.php.net/note/reject/107588
Search -- https://master.php.net/manage/user-notes.php