designer-trying-coding
designer-trying-coding

Reputation: 6064

Drupal 6 & PHP: how to crop part of string with php

I'm a newbie php guy.

I have 1 string output from Drupal's date module as below;

Dec 5 2010 (All day) - Dec 7 2010 (All day)

and I need to display only date, without (All day).

So, how can I display it as below? is there any php func that I can crop some parts of string?

Dec 5 2010 - Dec 7 2010

appreciate helps!! thanks a lot!

Upvotes: 2

Views: 221

Answers (2)

cypher
cypher

Reputation: 6992

$in_string = 'Dec 5 2010 (All day) - Dec 7 2010 (All day)';
$out_string = str_replace('(All day) ', '', $in_string);

Upvotes: 3

Tobias P.
Tobias P.

Reputation: 4665

$stripped = str_replace(' (All day)', '', 'Dec 5 2010 (All day) - Dec 7 2010 (All day)');

Upvotes: 1

Related Questions