0

这是一个读入 php 脚本的 .mov 文件。该文件并不总是相同的。

//[HMS Movie Line-Up File]
//[Version 3]
// Lineup=_2013_05
// Field definitions for movie category lines:
// 1. Category number (not used)
// 2. Movie category name
// 3. Regular price
// 4. Discount price
// 5. Type (Movies or Clips)
// 6. Has synopsis (1 = Yes)

// Field definitions for movie title lines:
// 1. Menu Name
// 2. Selection Number
// 3. Adult or Non-adult (1 = adult)
// 4. Asset Number
// 5. Account Code
// 6. Account Sub-Code
// 7. Rating
// 8. Running Time
// 9. No. of Files
// 10. File Name
// 11. Movie Name
// 12. Medium Type
// 13. Tape Leader Time  
// 14. Begin Date
// 15. Expire Date
// 16. Preview Start-Time 1
// 17. Preview Stop-Time 1
// 18. Preview Start-Time 2
// 19. Preview Stop-Time 2
// 20. Preview Start-Time 3
// 21. Preview Stop-Time 3
// 22. Playback Control
// 23. HDMI (1/0, 1 : use HDMI output)
// 24. MoviePackage
// 25. BitRate
// 26. HD/SD content (H for HD content, S for non-HD, H3 is HD with AC3 audio)
// 27. Aspect Ratio    (16:9 or 4:3)
// 28. Require HDCP (1/0, 1 is require)
// 29. Movie trailer aduio type (0:MPEG audio, 1:AC3 audio)

[Directory]
1   Category
1.1 hollywoodhd
1.2 mega
1.3 still
1.4 special
1.5 family

[Categories]
1   hollywoodhd 1295    1295    Movies  1
2   mega    1095    1095    Movies  1
3   still   1095    1095    Movies  1
4   special 895 895 Movies  1
5   family  1095    1095    Movies  1

[Titles]
  hollywoodhd1 1 0 8046 0 919 PG-13 6712 1 identity_hd "(HD) Identity Thief" Disk 0 04/15/13 11/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd2 3 0 8016 0 930 PG 5347 1 escapep_hd "(HD) Escape from Planet Earth" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd3 1 0 8012 0 930 PG-13 5828 1 darkski_hd "(HD) Dark Skies" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd3 2 0 8007 0 928 PG-13 5735 1 guilttri_hd "(HD) The Guilt Trip" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd3 3 0 8013 0 928 PG-13 7813 1 jackreac_hd "(HD) Jack Reacher" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd4 1 0 7993 0 919 PG-13 9500 1 lesmiser_hd "(HD) Les Miserables" Disk 0 03/06/13 09/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd4 2 0 7997 0 919 PG-13 6031 1 mama_hd "(HD) Mama" Disk 0 03/15/13 09/25/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd4 3 0 8018 0 930 PG-13 6930 1 safehave_hd "(HD) Safe Haven" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd6 1 0 7971 0 926 PG 5063 1 placetab_hd "(HD) A Place at the Table" Disk 0 03/01/13 09/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd7 3 0 7952 0 928 PG 5470 1 cirqueso_hd "(HD) Cirque du Soleil: Worlds Away" Disk 0 02/01/13 08/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd8 1 0 7948 0 928 PG 5829 1 riseguar_hd "(HD) Rise of the Guardians" Disk 0 02/01/13 08/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd8 3 0 7950 0 928 PG-13 5181 1 funsize_hd "(HD) Fun Size" Disk 0 02/01/13 08/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd9 2 0 7947 0 930 PG-13 6054 1 shanghai_hd "(HD) Shanghai Calling" Disk 0 02/01/13 08/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd12 2 0 7868 0 930 NR 5722 1 package_hd "(HD) The Package" Disk 0 12/01/12 06/05/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd12 3 0 7851 0 931 PG-13 6045 1 housend_hd "(HD) The House at the End of the Street" Disk 0 11/01/12 06/05/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  mega1 1 0 8060 0 702 PG-13 7413 1 beaucrea "Beautiful Creatures" Disk 0 05/01/13 10/15/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  mega1 2 0 8062 0 702 PG-13 6008 1 burtwond "The Incredible Burt Wonderstone" Disk 0 05/01/13 11/01/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  mega1 3 0 8063 0 702 PG-13 6850 1 jackgian "Jack the Giant Slayer" Disk 0 05/01/13 11/01/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  still1 2 0 7969 0 102 PG 6281 1 parental "Parental Guidance" Disk 0 02/15/13 08/01/13 0 0 0 0 0 0 1 0 0 3480400 S 4:3 0 0
  still1 3 0 7977 0 702 PG-13 10162 1 hobbit1 "The Hobbit: An Unexpected Journey" Disk 0 03/01/13 09/01/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  still2 1 0 7902 0 702 PG-13 10303 1 cloudatl "Cloud Atlas" Disk 0 02/01/13 09/01/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  still2 2 0 7936 0 102 PG 7619 1 lifepi "Life of Pi" Disk 0 01/15/13 07/15/13 0 0 0 0 0 0 1 0 0 3480400 S 4:3 0 0
  still3 2 0 7901 0 102 PG 6984 1 chasemav "Chasing Mavericks" Disk 0 01/01/13 07/01/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  still3 3 0 7872 0 102 PG-13 5529 1 taken2 "Taken 2" Disk 0 12/01/12 06/05/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  family1 1 0 7976 0 702 XXX 2418 1 arctic "Adult title 1" Disk 0 03/01/13 09/01/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  special1 1 0 5660 0 902 G 2743 1 fatdance "Fat Burning Hip Hop Dance Party" Disk 0 02/01/10 02/01/13 0 0 0 0 0 0 1 0 0 3500000 S 4:3 0 0
  special1 2 0 5659 0 902 G 2731 1 fatgroov "Fat Burning Hip Hop Dance Grooves" Disk 0 02/01/10 02/01/13 0 0 0 0 0 0 1 0 0 3500000 S 4:3 0 0
  special1 3 0 2266 0 903 G 4143 1 aladdin "Aladdin" Disk 0 02/01/04 12/31/20 0 0 0 0 0 0 0 0 0 3554800 S 4:3 0 0
  special2 1 0 3236 0 913 NR 5028 1 americno "Americano" Disk 0 11/01/05 10/31/15 0 0 0 0 0 0 0 0 0 3500000 S 4:3 0 0
  special2 2 0 3410 0 913 NR 6002 1 missbren "Missing Brendan" Disk 0 06/01/06 05/31/17 0 0 0 0 0 0 0 0 0 3500000 S 4:3 0 0
  special2 3 0 2407 0 913 NR 5946 1 pointdoo "Point Doom" Disk 0 06/01/06 05/31/17 0 0 0 0 0 0 0 0 0 3500000 S 4:3 0 0
  special3 1 0 2267 0 903 G 4528 1 gulliver "Gullivers Travels" Disk 0 02/01/04 12/31/20 0 0 0 0 0 0 0 0 0 3554800 S 4:3 0 0
  special3 3 0 2279 0 907 PG 5575 1 princess "The Little Princess" Disk 0 03/01/04 03/31/20 0 0 0 0 0 0 0 0 0 3500000 S 4:3 0 0
  special4 1 0 2278 0 907 PG 4915 1 jackbean "Jack And The Beanstalk" Disk 0 03/01/04 03/31/20 0 0 0 0 0 0 0 0 0 3500000 S 4:3 0 0
  family1 1 0 7976 0 702 G 2418 1 arctic "To the Arctic" Disk 0 03/01/13 09/01/13 0 0 0 0 0 0 1 0 0 3480400 S 16:9 0 0
  family1 1 0 7976 0 702 XXX 2418 1 arctic "Adult title 2" Disk 0 03/01/13 09/01/13 0 0 0 0     0 0 1 0 0 3480400 S 16:9 0 0

这是我拥有的解析数据的 PHP 脚本。我想解析数据,所以它只需要单词 [Titles] 之后的所有内容

<?php
header("content-type: text/plain");

foreach (glob("*.mov") as $filename)

$theData = file_get_contents($filename) or die("Unable to retrieve file data");

$string = $theData;
$titles = explode("\n", $string);
//unset($titles[0]);

function getInfo($string){
    $Ratings = ['G', 'PG', 'PG-13', 'R', 'NR', 'XXX'];
    $split = preg_split("/\"(.+)\"/", $string, -1, PREG_SPLIT_DELIM_CAPTURE);
    $string = $split[1];
    preg_match("/(".implode("|", $Ratings).")\s/", $split[0], $matches);
    $rating = $matches[0];
    return ["title" => $split[1], "rating" => $rating];
}

foreach($titles as $title){
    $info = getInfo($title);
    echo "{$info["title"]} : {$info["rating"]}\n";
}

现在它可以工作,但它也输出其他东西。请参阅下面的输出。任何人都知道我如何只能在 [Titles] 一词之后解析数据?谢谢你。如果向下滚动,您将看到我试图获取的实际数据。

<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : G 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
(HD) Identity Thief : PG-13 
(HD) Escape from Planet Earth : PG 
(HD) Dark Skies : PG-13 
(HD) The Guilt Trip : PG-13 
(HD) Jack Reacher : PG-13 
(HD) Les Miserables : PG-13 
(HD) Mama : PG-13 
(HD) Safe Haven : PG-13 
(HD) A Place at the Table : PG 
(HD) Cirque du Soleil: Worlds Away : PG 
(HD) Rise of the Guardians : PG 
(HD) Fun Size : PG-13 
(HD) Shanghai Calling : PG-13 
(HD) The Package : NR 
(HD) The House at the End of the Street : PG-13 
Beautiful Creatures : PG-13 
The Incredible Burt Wonderstone : PG-13 
Jack the Giant Slayer : PG-13 
Parental Guidance : PG 
The Hobbit: An Unexpected Journey : PG-13 
Cloud Atlas : PG-13 
Life of Pi : PG 
Chasing Mavericks : PG 
Taken 2 : PG-13 
Adult title 1 : XXX 
Fat Burning Hip Hop Dance Party : G 
Fat Burning Hip Hop Dance Grooves : G 
Aladdin : G 
Americano : NR 
Missing Brendan : NR 
Point Doom : NR 
Gullivers Travels : G 
The Little Princess : PG 
Jack And The Beanstalk : PG 
To the Arctic : G 
Adult title 2 : XXX 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>15</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\xampp\htdocs\test2.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined offset: 1 in <b>C:\xampp\htdocs\test2.php</b> on line <b>18</b><br />
 : 
4

1 回答 1

0

将函数和 foreach 修改为如下所示:

function getInfo($string){
    $Ratings = ['G', 'PG', 'PG-13', 'R', 'NR', 'XXX'];
    $split = preg_split("/\"(.+)\"/", $string, -1, PREG_SPLIT_DELIM_CAPTURE);
    if(count($split) == 3){
        $string = $split[1];
        preg_match("/(".implode("|", $Ratings).")\s/", $split[0], $matches);
        $rating = $matches[0];
        return ["title" => $split[1], "rating" => $rating];
    }
    return false;
}

foreach($titles as $title){
    $info = getInfo($title);
    if($info !== false){
        echo "{$info["title"]} : {$info["rating"]}\n";
    }
}
于 2013-05-31T19:42:05.633 回答