Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

array with one value converted to string? [duplicate]

Tags:

php

Possible Duplicate:
Get first element of array
Convert array to string php

I have this array: $ tab.

I perform a print_r() it has just this:

Array ( [0] => integration ).

How to get the value integration without doing $tab[0]?

like image 696
Ndiol Dia Avatar asked Dec 29 '11 12:12

Ndiol Dia


3 Answers

you could use:

current($tab);
array_shift($tab); // if you don't need to use the array for anything afterwards

Id question why it's in an array in the first place if you don't need it to be and what the issue with using $tab[0] is

like image 167
James C Avatar answered Nov 15 '22 22:11

James C


Well... $tab[0] would probably do what you want. I don't see why you wouldn't want that.

Anyway, getting the string should also be possible with current($tab).

like image 42
Tom van der Woerdt Avatar answered Nov 16 '22 00:11

Tom van der Woerdt


list($integration) = $tab;

echo $integration;
//"integration"
like image 44
Esailija Avatar answered Nov 16 '22 00:11

Esailija