相关疑难解决方法(0)

我什么时候使用PHP常量"PHP_EOL"?

什么时候使用是个好主意PHP_EOL

我有时会在PHP的代码示例中看到这一点.这会处理DOS/Mac/Unix终结问题吗?

php eol

347
推荐指数
8
解决办法
34万
查看次数

PHP在Foreach循环中有一个"内置"迭代器吗?

我正在使用foreach循环来遍历REQUEST数组,因为我希望有一种简单的方法来利用REQUEST数组的键和值.

但是,我还想要一个循环运行次数的数字索引,因为我正在编写一个包含PHPExcel的电子表格,我想使用该SetCellValue函数.我在想这样的事情:

foreach( $_REQUEST as $key => $value){
    $prettyKeys = ucwords(preg_replace($patt_underscore," ",preg_replace($patt_CC,"_",$key)));
    $prettyVals = ucwords(preg_replace($patt_underscore," ",preg_replace($patt_CC,"_",$value)));
    // Replace CamelCase with Underscores, then replace the underscores with spaces and then capitalize string
    // "example_badUsageOfWhatever" ==> "Example Bad Usage Of Whatever"


    $myExcelSheet->getActiveSheet()->SetCellValue( "A". $built-in-foreach-loop-numerical-index ,$prettyKeys);
    $myExcelSheet->getActiveSheet()->SetCellValue( "B". $built-in-foreach-loop-numerical-index ,$prettyVals);
}
Run Code Online (Sandbox Code Playgroud)

我知道我可以很容易地实现类似$c = 0outsite foreach的东西,然后每次循环运行时只增加它,但是有更清洁的东西吗?

php foreach iterator phpexcel

11
推荐指数
2
解决办法
1万
查看次数

标签 统计

php ×2

eol ×1

foreach ×1

iterator ×1

phpexcel ×1