小编Anu*_*lan的帖子

如何用PHP获得第二个?

假设一个数组有以下数据:

2,test
3,example
4,test,example
Run Code Online (Sandbox Code Playgroud)

我想获取数据:

test
example
test,example
Run Code Online (Sandbox Code Playgroud)

我用$a=explode(','$data);,然后回声$a[1].

但第三个输出是test.怎么弄test,example

php

0
推荐指数
1
解决办法
113
查看次数

如何动态切换div id

我有4个div彼此相邻,每个div包含一个链接.我想动态切换"当前"的id,

例如.

<div name="1" id="current">
<a>
link
</a>
</div>
<div name="2">
<a>
link
</a>
</div>
<div name="3">
<a>
link
</a>
</div>
<div name="4">
<a>
link
</a>
</div>
Run Code Online (Sandbox Code Playgroud)

如何在单击链接时动态更改当前的哪一个?

html css web

0
推荐指数
1
解决办法
406
查看次数

java:如何实现StringBuilder的replaceAll方法

我用matcher实现了replaceAll()方法,用""替换所有标点符号.但它总是抛出异常:" java.lang.StringIndexOutOfBoundsException:String index out of range:6 "

private static StringBuilder filterPunctuation(StringBuilder sb){
    Pattern pattern =  Pattern.compile("(\\.)");
    Matcher matcher = pattern.matcher(sb);
    while(matcher.find()){
        sb.replace(matcher.start(), matcher.end(), "");  
// if sb.replace(matcher.start(),matcher.end()," "), it wil be right, but I want replace all punction with ""
    }
    return sb;
}

public static void main(String[] args){
    System.out.println(filterPunctuation(new StringBuilder("test.,.")));
}
Run Code Online (Sandbox Code Playgroud)

java

0
推荐指数
1
解决办法
4460
查看次数

Echo foreach循环内部数组

我有以下代码,当我尝试$test_array使用类似"111 222"的空格打印下面数组中的值时:

$test_array= array('111', '222');


// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Cache-Control: no-store, no-cache'); 
header('Content-Disposition: attachment; filename=data.csv');


$output = fopen('php://output', 'w');


$test_data = array(  
    array('Invoice #', 'Name', 'Email'),  
    array( $test_array, 'John', 'test@yahoo.com')  
);


foreach( $test_data as $row )  
{  
   fputcsv($output, $row, ',', '"');     
}  

fclose($output);
Run Code Online (Sandbox Code Playgroud)

php

-4
推荐指数
1
解决办法
1130
查看次数

标签 统计

php ×2

css ×1

html ×1

java ×1

web ×1