[ create a new paste ] login | about

Link: http://codepad.org/2DNv0xab    [ raw code | output | fork ]

PHP, pasted on Apr 24:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php

$companies = array(
  'apple' => 'AAPL',
  'baxter' => 'BAX'
);

$tweet = <<< TXT
this is bapple and apples
TXT;

foreach ($companies as $name => $ticker) {
  $tweet = preg_replace('/\b'.preg_quote($name).'s{0,1}\b/', "<b>{COMPANY|$ticker}</b>", $tweet);
}

var_dump($tweet);


Output:
1
string(40) "this is bapple and <b>{COMPANY|AAPL}</b>"


Create a new paste based on this one


Comments: