Jump to content

spaghettio05

New Members
  • Posts

    4
  • Joined

Profile Information

  • Gender
    Not Telling

spaghettio05's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oops, yes, my original code is correct (found the mistake in my other code from which it came). Thanks for the replies!
  2. Hi all, I can't seem to designate an array key by using a variable and I was wondering if this is possible. I'm looking to do something like this: <?php $key = "apple"; $arr = array($key => "fruit"); ?> Any suggestions would be appreciated!
  3. Great, thanks for the responses - it worked!
  4. I'm new to regex and having some difficulty. Here is some sample code: <?php $t = "Apple: blah blah blah 12 Mar 2003 http"; $pat = '/(Apple|Orange): (?P<extract>.+)(\d{1,2} \w{3} \d{4})? http/'; preg_match($pat, $t, $matches); print trim($matches["extract"]); ?> I have 2 questions: 1) I want it such that the day in the date can be either 1 or 2 digits, so I would like it to return "blah blah blah" instead of "blah blah blah 1". 2) I would also like the date to be optional (it may be there sometimes, not other times), but can't get it to work by adding a ? after the date grouping: $pat = '/(Apple|Orange:): (?P<extract>.+)(\d{1,2} \w{3} \d{4})? http/'; In this case it returns: "blah blah blah 12 Mar 2003" This seems simple but I can't figure it out. Help would be greatly appreciated!
×
×
  • 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.