Reputation: 1775
I am retrieving information from a string, lets call it $data and the output is as follows:
Array
(
[0] => John Doe
)
How can take the portion of the Full name and set that as a new string, say $fullname
the value of $fullname should be: John Doe
Upvotes: 0
Views: 43
Reputation:
You can directly pass that value within a variable and can easily access it
Lets Say
$data = array('Jon Doe'); // output Array([0] => Jon Doe)
$fullname = $data[0]; // initialized value within $fullname
echo $fullname; // output Jon Doe
Upvotes: 1
Reputation: 99
I think you can get the value even without using "=>". Even if that is not used, the system takes "John Doe" as 0th value of that array only. It simply can be,
$data = array("John Doe");
echo $data[0];
Upvotes: 0
Reputation: 31749
It is not a string
. It is an array
. And you can access array element by its index
es. like -
$data = array(0 => "John Doe");
echo $data[0];
Upvotes: 0