elements from functions that return arrays

From: M. Katz (MKatz843_at_onebox.com)
Date: 01/31/04


Date: 31 Jan 2004 01:01:13 -0800

I'd like to access a single element from a function that returns an
array; and I'd like to do it in a single statement.

Here's an example. This is obvious.
$a = explode(".", "this.is.some.text");
$b = $a[2];

So how can I do that in a single statement?
$a = explode(".", "this.is.some.text")[2] // no
$a = (explode(".", "this.is.some.text"))[2] // nope
$a = [explode(".", "this.is.some.text")][2] // no way

How close am I coming to the final result. My goal is to be able to
nest them.

I was looking for an answer in the array functions, but the ones I
found don't return a scalar value, they return arrays in my cases.

Thanks,
M. Katz



Relevant Pages

  • Re: elements from functions that return arrays
    ... > I'd like to access a single element from a function that returns an ... and I'd like to do it in a single statement. ... > I was looking for an answer in the array functions, ...
    (comp.lang.php)
  • Re: elements from functions that return arrays
    ... Mike Bradley http://www.gzentools.com -- free online php tools "M. Katz" wrote in message ... > I'd like to access a single element from a function that returns an> array; and I'd like to do it in a single statement. ... > I was looking for an answer in the array functions, but the ones I> found don't return a scalar value, they return arrays in my cases. ...
    (comp.lang.php)
  • Re: reinitialization an array
    ... I would like to know is there any possible to reinitialization an ... array of big size to zero with a single statement. ...
    (comp.lang.c)
  • elements from functions that return arrays
    ... I'd like to access a single element from a function that returns an ... So how can I do that in a single statement? ... I was looking for an answer in the array functions, ... M. Katz ...
    (comp.lang.php)
  • Re: ttk::checkbutton - I think, its a bug
    ... linked to an array entry (with a dedicated array for ... a single statement: [array get $formVar]. ...
    (comp.lang.tcl)