| | |
act directly on an array value returned by a function?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Is there a way to act directly on an array value returned from a function without assigning it to another variable first?
For example, if I just want the third value in a CSV record, I might like to do it like this:
But that doesn't work. I've also tried with parentheses and/or curly braces in different positions around the preg_split().
Thank you.
--
Ghodmode
For example, if I just want the third value in a CSV record, I might like to do it like this:
PHP Syntax (Toggle Plain Text)
$value = preg_split('/,/', "one,two,three,four")[2];
Thank you.
--
Ghodmode
I use list and explode.
PHP Syntax (Toggle Plain Text)
list( ,,$value ) = explode( ',','one,two,three,four' ); echo $value; //returns three
Google is your friend.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
![]() |
Similar Threads
- Passing 2D Array of Pointers into a function (C++)
- Passing An Array Back From A Function (Visual Basic 4 / 5 / 6)
- array inside a function.... BORLAND C++ (C++)
- help passing an array of structs to a function? (C++)
- Returning 2-dimensional array, how? (C)
- Array filtering (PHP)
- [Warning] address of local variable returned??? (C++)
- Problem in displaying returned value from function (C#)
- Passing array of structures into a function (C++)
Other Threads in the PHP Forum
- Previous Thread: Formated Source Code
- Next Thread: hyperlink to last page
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess 301 access ajax apache api array beginner binary broken cakephp checkbox class cms code compression cron curl database date directory display download dropdown dynamic echo email error file files folder form forms function functions google href htaccess html httppost image include insert integration ip java javascript joomla limit link login loop mail md5 menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search secure select server sessions sms soap source space speed sql structure syntax system table tutorial update upload url validation validator variable video votedown web xml youtube






