extract strings from one long strings

shaymiller

Regular Member
Joined
Dec 3, 2016
Messages
456
Reaction score
45
I scrape a website with the title "Jhooti Episode 17 Ary Digital Drama - 16th May 2020 - Video Watch Online - Part 1"

Drama name is Jhooti
Episode is 17
Part 1

how can I extract this using php?

I have tried this

Code:
I could not post code here 

I used 
 substr and strpos functions
 
Since it's just a scraper, either post the code you already have, or go to stackoverflow
 
I could not post code here.

scaper has nothing to do with this

Just take that simple string I posted & let me know how to extract it using php




little bit more details

Will the title format change?
 
Split this string by „episode” and „-„ then get Your desired strings from returned arrays
 
You can split string by empty space and
than use first two elements from array
along with last two elements of array.
 
PHP:
$str = "Jhooti Episode 17 Ary Digital Drama - 16th May 2020 - Video Watch Online - Part 1";

if ( preg_match("/(.+)\s+Episode\s+(\d+).+Part\s+(\d+)/i", $str, $result ) ) {
    echo "name:" . $result[1] . "\n";
    echo "episode:" . $result[2] . "\n";  
    echo "part:" . $result[3] . "\n";  
}
 
$str = "Jhooti Episode 17 Ary Digital Drama - 16th May 2020 - Video Watch Online - Part 1"; if ( preg_match("/(.+)\s+Episode\s+(\d+).+Part\s+(\d+)/i", $str, $result ) ) { echo "name:" . $result[1] . "\n"; echo "episode:" . $result[2] . "\n"; echo "part:" . $result[3] . "\n"; }

Yes, it worked.

How can I extract date too?
 
Back
Top