Reputation: 1131
I am trying to split a string a a specific words ie.
$whois = "Record last updated on 10-Apr-2011.Record expires on 08-Oct-2012.Record Expires on 08-Oct-2008.";
preg_split('/Expires|expires/', $whois, $expires);
echo "<pre>";
print_r($expires);
Scratching my head over this tried lots of different solutions need help. Just want the string to be split up like it does with explod but at the word.
So i would get something like this.
array([0]=>'expires on 08-Oct-2012.Record',[1]=>'Expires on 08-Oct-2008.')
help
Upvotes: 0
Views: 2914
Reputation: 770
$whois = "Record last updated on 10-Apr-2011.Record expires on 08-Oct-2012.Record Expires on 08-Oct-2008.";
preg_match_all("/expires on [0-9]{2}-[a-z]{3}-[0-9]{4}/i", $whois, $expires);
print_r($expires[0]);
Close, but requires this strict format: "expires on 00-abc-0000"
Upvotes: 0
Reputation: 8079
this is the closest i could make
<?php
$whois = "Record last updated on 10-Apr-2011.Record expires on 08-Oct-2012.Record Expires on 08-Oct-2008.";
$expires = preg_split('/Expires|expires/', $whois);
array_shift($expires);
echo "<pre>";
print_r($expires);
?>
gives
Array
(
[0] => on 08-Oct-2012.Record
[1] => on 08-Oct-2008.
)
Upvotes: 1