1

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"
  • 1
    I will suggest you to read [this](http://stackoverflow.com/questions/3406171/php-var-dump-vs-print-r) – Rikesh Apr 04 '14 at 05:40

3 Answers3

2

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

Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
0

Please try following code:

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

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

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

Abhinav
  • 8,028
  • 12
  • 48
  • 89