$arr = array('id1','id2',...开发者_JAVA技巧);
How to get #id1,#id2,..
from the above array?
$arr = array('id1', 'id2', ...);
$ids = '#' . join(',#', $arr);
echo $ids; // => #id1,#id2,...
$arr[0];
$arr[1];
The code you just provided is the same as
$arr = array(
0 => "id1",
1 => "id2");
In order to make a list of ids in CSS
$string = '';
foreach($arr as $id)
{
$string .= "#" . $id . " ";
}
you can iterate the array
foreach ($arr as $k){
print "#".$k."\n";
}
each "$k" is your array items
精彩评论