我如何只从var转储数组中获取值?

Is it possible to escape array(1) { [0]=> string(12)} from var_dump($variable) because I want to show only values from var_dump and except array string?

Testing Code

 <?php
 $array = array(
 "foo" => "bar",
 "bar" => "foo",
 100   => -100,
-100  => 100,
 );
 var_dump($array);
 ?>

now results will be like this

array(4) {
["foo"]=>
string(3) "bar"
["bar"]=>
string(3) "foo"
[100]=>
int(-100)
[-100]=>
int(100)
}

But I want to get only bar and foo values except string(3) and array(4)?

Try

<?php
  $array = array(
    "foo" => "bar",
    "bar" => "foo",
    100   => -100,
    -100  => 100,
  );

  echo '<pre>';
  print_r($array);
  echo '</pre>';
?>
<?php
$array = array(
    "foo" => "bar",
    "bar" => "foo",
    100   => -100,
    -100  => 100
);

print_r($array);

$newArray = array_filter($array, function($v) {
    return (gettype($v) != 'string');
});

print_r($newArray);
?>

Outputs:

Array
(
    [foo] => bar
    [bar] => foo
    [100] => -100
    [-100] => 100
)
Array
(
    [100] => -100
    [-100] => 100
)

$newArray contains all values except strings. (you can change != to == to get only the string values)

After your edit I think you may want this (accessing individual items in an associative array):

echo $array['bar'];
echo $array['foo'];

Outputs:

foo
bar

Right here:

foreach ($array as $key => $value){
    echo $key.'=>'.$value."
";
}

For each key-value pair, this will echo the items as desired.

You could do:

call_user_func_array('var_dump', $array);

That is using var_dump() on each value of the $array instead of the whole array:

$array = array(
    "foo" => "bar",
    "bar" => "foo",
    100   => -100,
    -100  => 100,
);

call_user_func_array('var_dump', $array);

echo implode(', ', $array); # for comparison

Output:

string(3) "bar"
string(3) "foo"
int(-100)
int(100)
bar, foo, -100, 100

http://php.net/manual/en/function.array-values.php

$array = array(
    "a" => "bar",
    "b" => "foo",
);


var_dump($array);
//bar
//foo