note 110571 deleted from function.explode by aharvey
| From: | aharvey@php.net | Date: | Fri, 09 Nov 2012 00:46:01 +0000 |
| Subject: | note 110571 deleted from function.explode by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191817@lists.php.net to get a copy of this message | ||
Note Submitter: jorgex0 dot o at gmail dot com
----
Since version 5.4 I think (Won't work on 5.3.x), you can do this:
<?php
$fileName = explode( '.' , 'file.bin' ) [0] . '.txt';
print_r( $fileName ); // file.txt
?>
Which will get the part 0 of the returned array without the need for asigning it first and then
getting the first part:
<?php
$fileName = explode( '.' , 'file.bin' );
$fileName = $fileName[0] . '.txt';
print_r( $fileName ); // file.txt
?>