我想使用php从源代码中获取一些数据。我用
读取html源代码Name Null Type
-------------------- -------- -------------
EMP_ID NOT NULL VARCHAR2(13)
EMP_NAME VARCHAR2(50)
EMP_NAME_BANG VARCHAR2(150)
EMP_GENDER NUMBER(1)
EMP_CATEGORY NUMBER(1)
EMP_OFFICE NUMBER(7)
EMP_DESIGNATION NUMBER(4)
EMP_DATE_OF_JOINING DATE
EMP_GRADE NUMBER(2)
EMP_SLAB NUMBER(2)
EMP_BASIC NUMBER(7)
EMP_PHOTO_UPLOAD VARCHAR2(500)
CREATED_ON DATE
CREATED_BY VARCHAR2(10)
EMP_BIRTH_DATE DATE
EMP_EMAIL VARCHAR2(50)
EMP_PHONE VARCHAR2(15)
EMP_ACCOUNT_NO VARCHAR2(50)
EMP_BANK_NAME VARCHAR2(50)
EMP_APPOINTMENT_TYPE NUMBER(1)
我得到了所有的HTML代码。 在源代码中它就像那样
<?php
$source = file_get_contents('www.site.com');
?>
<textarea style="width:800px;height:600px"><?php echo $source;?></textarea>
和其他html标签
我只想将数据[Date.UTC(2013,9,2,10,30,0),972]作为数组
答案 0 :(得分:-1)
通过避免性能,它可能很有用
<?php
$s = "<script type='text/javascript'>
rangeSelector: {
inputEnabled: $('#container').width() > 480,
buttons: [{
type: 'day',
count: 3,
text: '3d'
},
series: [{
name: 'Rate',
data: [
[Date.UTC(2013,9,2,10,30,0),972]
,[Date.UTC(2013,9,2,11,30,0),973]
,[Date.UTC(2013,9,2,12,30,0),972]
,[Date.UTC(2013,9,2,13,30,0),972]
,[Date.UTC(2013,9,2,14,30,0),972]
,[Date.UTC(2013,9,2,15,30,0),972]
,[Date.UTC(2013,9,3,10,30,0),972]
,[Date.UTC(2013,9,3,11,30,0),972]
,[Date.UTC(2013,9,3,12,30,0),972]
],
</script>";
$arr = array();
while (strpos($s,"Date.UTC("))
{
$i = strpos($s,"Date.UTC")+8;
$val = substr($s,$i);
$val = substr($val,0,strpos($val,"]"));
$arr[] = $val;
$s = substr($s,$i);
}
var_dump($arr);
?>
结果:
array (size=9)
0 => string '(2013,9,2,10,30,0),972' (length=22)
1 => string '(2013,9,2,11,30,0),973' (length=22)
2 => string '(2013,9,2,12,30,0),972' (length=22)
3 => string '(2013,9,2,13,30,0),972' (length=22)
4 => string '(2013,9,2,14,30,0),972' (length=22)
5 => string '(2013,9,2,15,30,0),972' (length=22)
6 => string '(2013,9,3,10,30,0),972' (length=22)
7 => string '(2013,9,3,11,30,0),972' (length=22)
8 => string '(2013,9,3,12,30,0),972' (length=22)