开发者

PHP Array Operation

$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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜