1

Basically I'll be having a string that looks like

#schedule take out trash #in 20

and I need to be able to pull out "take out trash" and "20" and put them in their own variables. Possible?

1
  • Yes it's possible. What have you tried? Commented Dec 17, 2010 at 6:11

2 Answers 2

2

Use preg_match, for example

if (preg_match('/#schedule (.+?) #in (\d+)/', $string, $matches)) {
    // found matches
    $instruction = $matches[1];
    $time = $matches[2];
}
Sign up to request clarification or add additional context in comments.

Comments

1

list($task, $delay) = preg_split("/\s?#(\w+)\s?/")

should work for anything in that general format unless you need to worry about people putting # in the task name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.