Hi there,

I am trying to create a custom module to find a specific data within the website.

There are many stock tickers that end with ":US" in my database, but i do not what the ":US" after the ticker.

Example: The ticker "FB:US" will need to be "FB" - so I need to drop the ":US" from the ticker.

So some how i need to build a module to search the database for all of the tickers that end with ":US" and if the module does find one that ends in the ":US" then I only want the ":US" to be removed from the ticker.

Any ideas?

Thanks guys!

Comments

Jaypan’s picture

$results = db_query('SELECT ticker FROM {ticker_table} WHERE ticker LIKE :value', array(':value' => '%:us'));
$tickers = array();
foreach($results as $r)
{
  $tickers[] = str_replace(':US', '', $r->ticker);
}

$tickers will contain all of your values, stripped of the ':US' at the end of the ticker.