Jump to content

Getting only Capital words


A584537

Recommended Posts

Hi, I'm using a C program to get a html page from a site, because I don't know how to use PHP sockets yet.
And, I'm using PHP to strip the tags and change   to a space and such.

What I need though, is to only get capitalised words. Here's an example:

[code]
CLERKS II

Sequel to Clerks. A calamity at Dante and Randall's shops sends them looking for new horizons...
CLICK

Michael Newman’s life is transformed when he is given a universal remote to control his life.
DIRTY SANCHEZ

An extreme version of Jackass.
[/code]
I only want the movie titles, and luckily they are all capitalised.
I want to get the capitalised words out of a string, $contents2.

How would I go about this?

Cheers
Link to comment
Share on other sites

[code]
<pre>
<?php

$data = <<<DATA
CLERKS II

Sequel to Clerks. A calamity at Dante and Randall's shops sends them looking for new horizons...
CLICK

Michael Newman’s life is transformed when he is given a universal remote to control his life.
DIRTY SANCHEZ

An extreme version of Jackass.
DATA;

preg_match_all('/([A-Z][A-Z ]+)\s/', $data, $matches);
print_r($matches);

?>
</pre>
[/code]

[quote]
Array
(
    [0] => Array
        (
            [0] => CLERKS II
            [1] => CLICK
            [2] => DIRTY SANCHEZ
        )

    [1] => Array
        (
            [0] => CLERKS II
            [1] => CLICK
            [2] => DIRTY SANCHEZ
        )

)
[/quote]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.