I am not interested in the values in the arrays, how can I discard them?
<?php
$values = array(10=>"I","Don't","Care","About","Values");
print_r($values);
$whatvalues = array_keys($values);
print_r($whatvalues);
?>
Here is the resultant output from this:
Array
(
[10] => I
[11] => Don't
[12] => Care
[13] => About
[14] => Values
)
Array
(
[0] => 10
[1] => 11
[2] => 12
[3] => 13
[4] => 14
)
We can see that the values have been discarded and we now have an array containing the keys as the values.
Comment on this Question and Answer >>>
ASK A QUESTION
More arrays PHP Questions
How do I change: function wordlimit($string, $length = 50, $ellipsis = "...") { $words = explode(' ', strip_tags($string)); if (count($words) > $length) return implode(' ', array_slice($words, 0, $length)) . $ellipsis; elseHow do I pick a random value from an array?
How can I mix up the order of values in an array?
How do I sort alphanumeric array data correctly?
How do I sort the members of an array by value?
