0

still learning some of the finer parts of PHP, i have a function that returns an array of arrays. And on the times that it is only returning a single "array" i use the below code to save having to reference it as a multi dimensional array. Is there a way to do this on a single line of code? i know it doesnt make much of a differance in this specific scenrio, but just curious if i am missing a short hand of php that might be handy other times.

$res_resource=fetch($stmt_resource);  //returns array of arrays
$res_resource=$res_resource[0];
Schugs
  • 89
  • 3
  • 13

1 Answers1

1

As of PHP 5.4.0:

$res_resource = fetch($stmt_resource)[0];
AbraCadaver
  • 78,200
  • 7
  • 66
  • 87
  • Thank you for your response. I actually tried this, but Dreamweaver views it as an error, so i assumed it didnt work. While this does work in php 5.4, unfortunetly because Dreamweaver views it as an error, code hint stops working, which is not a good trade off :-D. Thank you again for your response, and this definetly works and functions as intended. – Schugs Jun 25 '14 at 17:46