2014-01-08 146 views
-5

我使用curl和php登錄網站。 捲曲的迴應是: -從curl響應中獲取particuler數據

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 

我要像

$a=41, 
$b=BAIL/3724/2013, 
$dateTime=12:46:41 08/01/2014 

供以後use.thanks

+0

'的print_r(爆炸( '〜',$ yourresponse));'嘗試。 –

+0

先生,我想分裂線兩個charecter |和〜用於在'|'上使用循環取回值 – AAKASH

+1

[explode()](http://www.php.net/manual/en/function.explode.php),然後[sscanf()](http:或許呢? –

回答

1

後做特殊

| and ~ 

和存儲數據的不同變量分割字符串像這樣..

<?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>"; 

} 

OUTPUT:

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