if (preg_match_all('#instagr.am/p/([\d\w]+)#i', $tmp, $matches, PREG_PATTERN_ORDER) > 0) {
        foreach ($matches[1] as $key => $match) {
            $text = "<a href='http://{$matches[0][$key]}'><img src='http://instagr.am/p/{$match}/media' /></a><br />".$text;
        }
    }
    if (preg_match_all('#picplz.com/([\d\w]+)#i', $tmp, $matches, PREG_PATTERN_ORDER) > 0) {
        foreach ($matches[1] as $key => $match) {
            $text = "<a href='http://{$matches[0][$key]}'><img src='http://picplz.com/{$match}/thumb/400' /></a><br />".$text;
        }
    }