note 107588 deleted from function.strstr by sobak

From: Date: Fri, 25 Nov 2016 05:12:20 +0000
Subject: note 107588 deleted from function.strstr by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207619@lists.php.net to get a copy of this message
Note Submitter: peter at olds dot co ---- 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 :)

« previous php.notes (#207619) next »