小编Sha*_*ads的帖子

在PHP中以大写字母分割?

我发现了这个类似的问题,但它没有回答我的问题,大写字母拆分.

我有一个骆驼案的字符串.我想在每个大写字母中分解该字符串,如下所示.

$str = 'CamelCase'; // array('Camel', 'Case');
Run Code Online (Sandbox Code Playgroud)

我到目前为止:

$parts = preg_split('/(?=[A-Z])/', 'CamelCase');
Run Code Online (Sandbox Code Playgroud)

但是结果数组总是在开头时以空值结束!$parts看起来像这样

$parts = array('', 'Camel', 'Case');
Run Code Online (Sandbox Code Playgroud)

如何摆脱数组开头的空值?

php preg-split

10
推荐指数
1
解决办法
3648
查看次数

在彩色方块上创建半透明的内部笔划?

我在画布上绘制不同颜色的方块,固定大小为50px x 50px.

我已经成功地为这些彩色方块添加了5px的透明内部笔划,但它看起来像我做的那样大规模过度杀伤.

ctx.fillStyle = this.color;
ctx.fillRect(this.x, this.y, engine.cellSize, engine.cellSize);
ctx.fillStyle = 'rgba(0, 0, 0, 0.2)';
ctx.fillRect(this.x, this.y, engine.cellSize, engine.cellSize);
ctx.fillStyle = this.color;
ctx.fillRect(this.x + 5, this.y + 5, engine.cellSize - 10, engine.cellSize - 10);
Run Code Online (Sandbox Code Playgroud)

有没有比绘制3个单独的矩形更好的方法来实现我追求的目标?

html5-canvas

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

标签 统计

html5-canvas ×1

php ×1

preg-split ×1