我使用curl和php登录网站。 卷曲响应是: -
41~BAIL/37246/2013~101~ILYAS~STATE OF U.P.~D~12:46:41 08/01/2014|44~A482/42266/2012~21~BHIKENDRA VARSHNEY~STATE OF U.P. AND ANOTHER~D~12:46:41 08/01/2014|44~A482/42647/2012~22~BHIKENDRA VARSHNEY~STATE OF U.P. AND ANOTHER~D~12:46:41 08/01/2014|51~BAIL/39156/2013~131~MANSURI ALAM~STATE OF U.P.~F~12:46:41 08/01/2014|52~CRLAD/68/2012~33~JALEES~STATE OF U.P.~D~12:46:41 08/01/2014|54~A482/46798/2013~191~MADHAU SINGH AND 2 ORS.~STATE OF U.P. AND ANOTHER~B~12:46:41 08/01/2014|54~A482/47074/2013~95~S.S.I. R.S.VERMA AND ANOTHER~STATE OF U.P. AND ANOTHER~F~12:46:41 08/01/201
我想在特殊的
后拆分字符串 | and ~
并存储数据不同的变量,如
$a=41,
$b=BAIL/3724/2013,
$dateTime=12:46:41 08/01/2014
供以后使用。谢谢
答案 0 :(得分:1)
这样做..
<?php
$str='41~BAIL/37246/2013~101~ILYAS~STATE OF U.P.~D~12:46:41 08/01/2014|44~A482/42266/2012~21~BHIKENDRA VARSHNEY~STATE OF U.P. AND ANOTHER~D~12:46:41 08/01/2014|44~A482/42647/2012~22~BHIKENDRA VARSHNEY~STATE OF U.P. AND ANOTHER~D~12:46:41 08/01/2014|51~BAIL/39156/2013~131~MANSURI ALAM~STATE OF U.P.~F~12:46:41 08/01/2014|52~CRLAD/68/2012~33~JALEES~STATE OF U.P.~D~12:46:41 08/01/2014|54~A482/46798/2013~191~MADHAU SINGH AND 2 ORS.~STATE OF U.P. AND ANOTHER~B~12:46:41 08/01/2014|54~A482/47074/2013~95~S.S.I. R.S.VERMA AND ANOTHER~STATE OF U.P. AND ANOTHER~F~12:46:41 08/01/201';
$arrel = explode('|',$str);
foreach($arrel as $val)
{
$new_el=explode('~',$val);
echo $new_el[0];
echo "<br>";
echo $new_el[1];
echo "<br>";
echo $new_el[6];
echo "<br><br>";
}
输出:
41
BAIL/37246/2013
12:46:41 08/01/2014
44
A482/42266/2012
12:46:41 08/01/2014
44
A482/42647/2012
12:46:41 08/01/2014
51
BAIL/39156/2013
12:46:41 08/01/2014
52
CRLAD/68/2012
12:46:41 08/01/2014
54
A482/46798/2013
12:46:41 08/01/2014
54
A482/47074/2013
12:46:41 08/01/201