user2761119
user2761119

Reputation: 55

using var_dump,value not returning in proper format

Here is my code:

foreach ($results as $result)
{
$getdata[] = $result->salt; 
$getdata[] = $result->password;
}

var_dump($getdata);
echo $sal->$getdata[0];
echo "<br>";
echo $pwd->$getdata[1];

Output:

array(2) { [0]=> string(3) "f9e" [1]=> string(64) "61eed489ddfa309ab764hj876bfhfa5d18e3c3e695edc15" } 

But i want the ouput like dis:

[0]=> "f9e" [1]=> "61eed489ddfa309ab764hj876bfhfa5d18e3c3e695edc15"

Upvotes: 1

Views: 138

Answers (3)

Abhinav
Abhinav

Reputation: 8168

Before printing the result, use

echo "<pre>";
print_r($result);

This will give you result in a neat understandable way

FYI:

The var_dump function displays structured information about variables/expressions including its type and value

The print_r() displays information about a variable in a way that's readable by humans. array values will be presented in a format that shows keys and elements

Upvotes: 0

Deep
Deep

Reputation: 1

Please try following code:

foreach ($results as $result) {
    $getdata[] = $result->salt; 
    $getdata[] = $result->password;
}

foreach ($getdata as $key => $value) {
    echo '[' . $key . '] => "' . $value . '" &nbsp;';    
}

Upvotes: 0

Sadikhasan
Sadikhasan

Reputation: 18600

You can use print_r($getdata) insted of var_dump($getdata)

Upvotes: 2

Related Questions