-1

Hopefully a simple problem but cant find the solution anywhere.

If I want to take any charactors before the "v" how would I do it?

Example:

Chelsea v Aston Villa - Match Betting;

I cant take the first word as sometimes it is two words like:

Man Utd v Blackburn - Match Betting;

Any help gratefully appreciated

Thanks

Richard

user989952
  • 661
  • 1
  • 12
  • 23

4 Answers4

4
$text = 'abc def v ghi jkl';
list($left, $right) = explode(" v ", $text, 1);
echo $left, ' v ', $right;
Alex
  • 11,479
  • 6
  • 28
  • 50
0

explode()

Example here: http://ideone.com/nQLhV

Paul
  • 20,883
  • 7
  • 57
  • 74
0

Do you mean like this:


$text = "Man Utd v Blackburn - Match Betting";
echo $first = array_pop(array_reverse(explode(" v ", $text))); // shows Man Utd

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
0
$str = "Chelsea v Aston Villa - Match Betting;";
$str = explode(" v ", $str);
$str = $str[0];
Pheonix
  • 6,049
  • 6
  • 30
  • 48