0

I saw this in a php script about reading a csv file:

 array($mydata);

What does it make? An array from $mydata?

1

1 Answer 1

1

Yes, it creates an array where $mydata is the first element. You can even put many elements in there at once:

php > $x = array(1,2,3);
php > var_dump($x);
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

However, if that was all that happened on that line, I'd say nothing happens at all. array() behaves like a function that returns a new array, if it wasn't assigned to anything it was simply discarded and nothing happened. Example:

php > $y = 'foo';
php > array($y);
php > var_dump($y);
string(3) "foo"
1
  • @Chiyou Just added a bit about that. Then nothing happens at all there really. Commented Jul 18, 2012 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.