在行的开头回显没有数字字符的行

时间:2014-04-12 21:47:24

标签: php database replace echo numeric

我在数据库中有一些行,都以数字开头:

1 some text
2 another text 
13 more text

我使用命令显示这些行

$title = "$chapter : {$row[0]}"

其中$ row [0]是上述示例的数据库中的任何选定行。

我需要的是让命令显示没有每行开头的数字的行。

我找到了一些选项,例如preg_replace(' / ^ [0-9] +。+ /','',$ string) - 但我不知道知道如何在命令中实现它们。

1 个答案:

答案 0 :(得分:0)

你可以做到

 $field = preg_replace('/^[0-9]+. +/', '', $row[0]);
 $title = $chapter ." : ".$field;