-
What's considered best practice for fixed-width sites?
I second this. For the time being working to 960px is probably the best way to go for fixed-width layouts. This width is ideal for users with the 1024x768 screen resolution. I very much doubt people are still using lower resolutions on a desktop computer.
-
-
Google Maps PHP Class
Hey guys, I thought my latest script might be of use to you. It simplifies the process of creating both dynamic (javascript-powered) and static google maps and adding markers to them. Check it out, tell me what you think. http://blog.james-bailey.com/google-maps-php-class/
-
Best registrar for .co.uk & .com domains? - who do you use?
Heart Internet is pretty good.
-
PHP string to boolean function?
No I didn't. He wanted a way to convert "Cars not motorbikes" into "Cars -motorbikes", thats what that function I wrote does. If someone types in 'Cars not motorbikes', it will convert 'not ' into '-' for the query. By the way when using full text searching, using the + sign isn't needed, typing '+chips -bread' is the same as 'chips -bread'.
-
-
Can anyone tell me why this layout doesn't work?
Thanks. Add this to the CSS code in the header. ul.list ul li { min-height:50px; max-height:50px; } ul.list li.name, #bname { width:180px; } It widens the name column and restricts the height to each list item to 50px, no more no less.
-
Help: Randomising results
Use the shuffle() function to randomize the array items. <?php function list_products($limit = 10) { $url = $this->productsapiurl . '?limit='. $limit; $result = $this->pull_data($url); $list = '<div style="width:100%; text-align:center;">'; // Randomize the order of the array items. shuffle($result); foreach ($result as $item) { $list .= '<a href="' . $this->producturl . $item->permalink . '" title="' . $item->name . '"><img src="' . $this->image_url($item->images->image[0]->url) . '" height="114" /><br />' . $item->name . '</a>'; } $list .= '</div>'; return $list; }
-
Can anyone tell me why this layout doesn't work?
Because the list items don't have a fixed height. Your better off using tables for something like that.
-
PHP string to boolean function?
Heres a starting point. <?php function format_query_criteria($string) { $string = preg_replace('/(not\s)/i', '-', $string); return $string; } echo format_query_criteria("Cars NOT motorbikes"); // echos: Cars -motorbikes
-
What Does Your Desktop Look Like
-
Using copyrighted Images from Nintendo.com
I'm not 100% sure on this but at college my multimedia teacher said if you take something thats copyrighted and you change it enough to show creativity it becomes yours. But you cant take something and use it as it is.
-
PHP devs stop doing things bad!
I agree. OOP has its place but can be overkill. I only tend to use OOP when writing plugins for applications or tinkering with a CMS core.
-
What are you worst at?
I'm really bad at designing layouts, I started making websites in 2002 so some of the things i learned back then about web design have changed since then but no matter how hard i try, my layouts look like there old and outdated :/
-
Keeping an active, popular blog with precious little free time?
Thanks guys! useful advice
-
Keeping an active, popular blog with precious little free time?
I started my blog PHP Monkey a little under a week ago now and I've published quite a few articles since. However I had a week off from work when i started it and am now struggling to find time to write some quality, interesting material so writing an article every day is going to be tricky. I just wanted some advice really, how do you run a blog when you work 9-5 monday to friday?
-
Extract google links for a game
I wrote this function a while ago, it could prove useful. Theres still one or two bugs in it i'll fix it when I have time. For example, it doesn't work correctly if link attribute values arn't wrapped in quotes. <?php /** *--------------------------------------------------------------------- * extract_links($content, $convert_html); *--------------------------------------------------------------------- * Takes in HTML content and extracts any links found. * * If argument 2 is set to TRUE, any HTML returned such as the * original link text is converted with htmlentities. * * It returns an array of arrays, each belonging to a link. * * Included in the array is: * - The original link (last element of array) * - The link's anchor text (second to last). * - The attributes & values as keys/values of the array (first). * * E.g. $html = '<div id="companies"> <a href="http://www.company.co.uk/" id="company-182" title="company info"><img src="uploads/adverts/company-182.jpg" alt="" /></a> <a href="#" title="show the next company" id="next-company" class="pagelink" style="display:block;margin-top:5px;">View next company</a> </div>'; echo "<pre>".print_r(extract_links($html), TRUE)."</pre>"; would output: Array ( [0] => Array ( [href] => http://www.company.co.uk/ [id] => company-182 [title] => company info [anchor_text] => <img src="uploads/adverts/company-182.jpg" alt="" /> [original_link] => <a href="http://www.company.co.uk/" id="company-182" title="company info"><img src="uploads/adverts/company-182.jpg" alt="" /></a> ) [1] => Array ( [href] => # [title] => show the next company [id] => next-company [class] => pagelink [style] => display:block;margin-top:5px; [anchor_text] => View next company [original_link] => <a href="#" title="show the next company" id="next-company" class="pagelink" style="display:block;margin-top:5px;">View next company</a> ) ) */ function extract_links($content, $convert_html=TRUE) { $content = str_replace("'", '"', $content); $links = array(); $matches = preg_split('/<a /', $content); unset($matches[0]); foreach ($matches as $index => $link) { // get anchor text. preg_match_all('/>(.*)<\/a>/', $link, $text); $text[0][0] = substr($text[0][0], 1); $text[0][0] = substr($text[0][0], 0, -4); $anchor_text = $text[0][0]; $link_xpl = explode('>', $link); // extract link attributes. preg_match_all( '/[a-zA-Z0-9]+[\=]{1}[\"\']{1}[a-zA-Z0-9;:.?&=\-\_\#\/\s]+[\"\']{1}/', $link_xpl[0], $attr ); foreach ($attr as $key => $value) { foreach ($value as $k => $v) { $xpl = explode('="', $v); $xpl[1] = preg_replace('/[\'\"]/', '', $xpl[1]); $value[$xpl[0]] = $xpl[1]; unset($value[$k]); } $original_link = $link; $xpl = explode('</a>', $original_link); $value['anchor_text'] = ($convert_html == TRUE) ? htmlentities($anchor_text) : $anchor_text; $value['original_link'] = ($convert_html == TRUE) ? htmlentities('<a '.$xpl[0].'</a>') : '<a '.$xpl[0].'</a>'; $attr[$key] = $value; } $links = array_merge($links, $attr); } return $links; }