php如何从数字后的字符串中获取文本

时间:2017-04-15 06:18:29

标签: php regex crop trim

我有:

$string = "Some minimal or large text 820 some minimal or large descr";

我需要: 一些最小或最大的描述

2 个答案:

答案 0 :(得分:1)

str_pos()怎么办?

<?php
  $string = "Some minimal or large text 820 some minimal or large descr";
  echo substr($string, strpos($string, '820') + 4);

答案 1 :(得分:1)

preg_split函数可以帮到你!

它将字符串拆分为一个转换它的数组..

http://www.php.net/manual/en/function.preg-split.php

$array = preg_split("/[0-9]+/", "Some minimal or large text 820 some minimal or large descr");
print_r($array);