English 中文(简体)
PHP获得头几个果园,从扼杀中除去
原标题:PHP get first few charactors and remove from string
  • 时间:2011-10-30 19:15:58
  •  标签:
  • php

是否有任何人知道如何从扼杀中去除头几个特征,并将这些特征移出植物检疫。

如同在座标中“地名” 我需要删除“字号”并节省“档案名称”。

但是,它必须去除太多的果园,才能进入“_”。

换言之,需要删除所有特征,直至并列入其中的第一份“_”。

最佳回答

你可以这样做:

if (strpos($string,  _ ) !== false)
   $string = substr($string, strpos($string,  _ ) + 1);

http://codepad.org/g12ENLGY”rel=“noreferer”http://codepad.org/g12ENLGY。

<说明>:if<>/code>很有用,因为你的方言不能有。

问题回答

您能使用这样的东西:

$files = explode("_", $filename);
echo $files[1];

因此,这将在<条码>_上分开,然后与第二部分(在强调之后)保持一致。

这假设只有一点强调。

Please see http://www.php.net/manual/en/function.explode.php

除使用<代码>explode外,还可采用其他解决办法。 如前所述,你可以使用以下办法解决:

^(?:[^_]*_)(.*)$

这里的一个例子是:

$str = "str_filename";
$pattern = "/^(?:[^_]*_)(.*)$/";
preg_match($pattern, $str, $matches);

echo $matches[1]; //prints "filename"




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...