Posts Tagged PHP
Pointless Fun With Twitter’s API
Or The Unsinkable Wilford Brimley.
Because when we are all dead and gone, He will remain.
Get ahold of somebody, get ahold of anybody! We gotta report this mess.
Needed something to test the regex function on for a new project and what’s better than inappropriate dead celebrity humor.
Using Regular Expressions with Twitter Search
Posted by Johnny in Design, PHP, Tech, TechMunchies on July 1, 2009
A new project has me using Twitter’s search api.
The json returns text of each message, which is to be expected, but many posts have “@soandso” or “http://is.gd/lko6g” or something, and that kind of info can’t just be left to sit there now can it?
No it can not.
However, a little regular expression magic and presto! Links GAlore.
Using preg_replace you can quickly and easily replace each text version of ‘@johnmangino’ with @johnmangino.
The only “trick” here is to use the parenthesis to give you a reference that will allow you to make the user link without the ‘@’.
Here is a quick function used within the loop to href the links.
Import the function and run the text through it like so:
$text = $r->text; $text = makeRich($text);
Hope you enjoy.
Yours truly,
$johnny
PHP to MySQL connection POLL
I’m a little curious where PHP developers are with fundamental MySQL connections these days. So here is a little poll. It closes on July 1st.
SELECTing From Multiple Tables in MySQL
Posted by Johnny in Design, PHP, Tech, TechMunchies on June 6, 2009
I needed to grab data from 3 tables in one query for a new app that is being built internally at work.
I was going through the tedious procss of a multiple table JOIN when I discovered I could greatly simplify things with this –
So I thought I would share.
I know the ‘if condition is wonky.
Technically I usually do:
$results=$mysql->query($q);
if($results)
{
...
}
but this seems faster to me.
No?







