我正在循环一个有长字符(长句)的行。正如你所看到的,我把一个" -
"在大块分裂结束时适当的句子休息。我只是想知道它为什么显示" - "在字符串的最后一端?
<td valign="top">'.chunk_split($row['interventions'],20,"-<br>").'</td>
答案 0 :(得分:2)
尝试使用rtrim()
chunk_split
<td valign="top">'.rtrim(chunk_split($row['interventions'],20,"-<br>"),"-<br>").'</td>
答案 1 :(得分:1)
以下是从字符串中删除特殊字符的方法。
How to remove last comma from string using php?
<td valign="top">'.rtrim(chunk_split($row['interventions'],20,"-<br>"), "-").'</td>
答案 2 :(得分:1)
你可以使用str_split来创建一个字符串数组,然后用implode将它连接起来 Implode不会以分隔符结束字符串。
//our root app component
import {Component, ViewChild, NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
@Component({
selector: 'my-app',
template: `<h1>Angular 2 Systemjs start</h1>
<img [src]="image" (click)="clearImage()">
`
})
export class App {
image = 'http://upload.wikimedia.org/wikipedia/commons/4/4a/Logo_2013_Google.png';
canvas : any;
context : any;
ngAfterViewInit() {
this.canvas = document.createElement("canvas");
this.context = this.canvas.getContext("2d");
let source = new Image();
source.crossOrigin = 'Anonymous';
source.onload = () => {
// this.context.beginPath();
this.canvas.height = source.height;
this.canvas.width = source.width;
this.context.drawImage(source, 0, 0);
this.context.font = "100px impact";
this.context.textAlign = 'center';
this.context.fillStyle = 'black';
this.context.fillText('TEST', this.canvas.width / 2, this.canvas.height * 0.8);
this.context.stroke();
this.image = this.canvas.toDataURL();
};
source.src = this.image;
}
clearImage()
{
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
}
}
@NgModule({
imports: [ BrowserModule ],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule
{}
$arr = str_split("abcdefghijklmn",5);
Echo implode("-<br>", $arr);
答案 3 :(得分:0)
这解决了
RSpec.describe ExtApi::BaseController, type: :controller do
describe "GET resp" do
it 'renders bar' do
get :resp, access_token: token
# expect ...
end
end
end
这里-5如果长度为
<td valign="top">'.substr(chunk_split($row['interventions'],20,"-<br>"), 0, -5).'</td>
获取帮助
答案 4 :(得分:-1)
有一个 - 字符:
<td valign="top">'.chunk_split($row['interventions'],20,"-<br>").'</td>
使用以下方法修复它:
<td valign="top">'.chunk_split($row['interventions'],20,"<br>").'</td>