GizzmoAsus.co.uk

Archive for December, 2007

Convert Linebreaks to New Lines

by on Dec.21, 2007, under PHP Code

Intro

During my development process I am forever using the same information for both text-based emails and html-based emails. Then a thought came accross me, why not just use the same information and replace the
with \n using some form of regular expressions. This lead to me doing a quick search on the net to ensure I wasn’t reinventing the wheel and I came accross the following:

Code

/* This function will convert line breaks or other tags passed in the 
$tags variable to linebreaks.  Multiple $tags must be separated by 
spaces, and must consist of the regular tag text. 
Ie. $result = br2nl($text_to_filter, "br p blockquote") */    

function br2nl($text, $tags = 'br')
{ 
    $tags = explode("e; "e;, $tags); 
    foreach($tags as $tag) { 
        $text = eregi_replace('<' . $tag . '[^>]*>', '\n', $text); 
        $text = eregi_replace(']*>', '\n', $text); 
    } 
    return($text); 
}

// Usage: $text_to_filter = '

This is my
sample
text. The default code listed here should replace the br's with new lines.

The second example is more advanced, stripping out both the BR's as well as the P tags.

'; // Example of replacing BR tags (default) $result = br2nl($text_to_filter); // Example of replacing both BR and P tags $result = br2nl($text_to_filter, "br p"); ?>

Function Found at http://www.warkensoft.com 

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Leave a Comment more...

Working at last

by on Dec.01, 2007, under Personal

Well since graduating, some of you may know that I have been job hunting with little success. I managed to find some temporary work with a company based at Preston called Xchanging. This involved processing (mainly) BAE temporary worker wage bills. Whilst this was an interesting change from the norm it really wasn’t what I wanted to do so I kept looking.

A couple of months back I went for a job interview with a company based in Lancaster for a developer position that had opened up. Unfortunately they decided to hire internally but then I recieved a phone call asking me if I wanted to work or them as a position had opened up. Needless to say I agreed and now a developer for the second largest online directory system on the internet (behind Yell). The work is mainly front-end changes for the time being but it is building up the experience I need to start working on the back-end infrastructure which is currently in place.

Anyway thats currently what I’m up to so check back to see how things develop on the work front. In the meantime feel free to check out a few mods for the FusionBB community on their site and my main site

Have fun and be good 😉

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!