a newbi question on php array
Array ( [inline_comment] => inline_comment [page] => page [comment] => Comment )
I want to array turn to be :~
Array ( [0] => inline_comment [1] => page [2] => Comment )
how to do t开发者_开发百科hat ?
<?php
$new = array();
foreach ($old as $entry) $new[] = $entry;
?>
or better
<?php
$new = array_values($old);
?>
$arr = array(
'inline_comment' => 'inline_comment',
'page' => 'page',
'comment' => 'Comment'
);
$arr = array_values($arr);
It's not entirely clear whether you want to get the keys or values from the array.
If you want to get the keys, then you probably want to look up the array_keys()
function
$new_array = array_keys($old_array);
I believe this will do exactly what you want.
If you want to get the values, then array_values()
will do what you want. It works in pretty much the same way as array_keys()
above.
精彩评论