什么时候使用是个好主意PHP_EOL?
我有时会在PHP的代码示例中看到这一点.这会处理DOS/Mac/Unix终结问题吗?
我正在使用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的东西,然后每次循环运行时只增加它,但是有更清洁的东西吗?