20 Sep
Posted by: admin in: PHP Solutions
We often need to create something for navigation. For example, we have a gallery that consists of 400 pictures and we’d like do create 40 pages to list 10 pictures per page. In this sample we will need to create a navigation bar that will allow us to switch between pages easily. It is ok [...]
10 Sep
Posted by: admin in: PHP Solutions
As you may know, all major Search Engines provide API interface for developers. It is possible to use search results in your applications; there is a variety of languages that can be used to retrieve search results. I will show you a PHP solution that allows to get Yahoo! Search results using a short script.
We [...]
06 Sep
Posted by: admin in: Apache Performance, PHP Solutions, Regexps
It is often necessary to extract text from a variable that contains HTML or XML code. I’ve created a simple regular expression that will help you to extract all text between certain tags into an array. It is a PHP solution, though regular expression is compatible with other programming languages.
preg_match_all(”/<tag>(.*?)<\/tag>/”, $source, $results);
This construsion will create [...]
If you’re working with text information, you often need to extract some parts of text from articles, web pages and so on. You can use regular expressions for this, but if you’re not familiar with them, you’ve got to use string functions of PHP.
When I didn’t know what regular expressions are, I’ve written a function [...]
04 Aug
Posted by: admin in: PHP Solutions
Sometimes you need to change the word order in a line for some reason. I am going to show you a PHP solution that allows you to create all possible word combinations from a string. The code below should explain you all operations that are performed.
<?
// Factorial
function fact($s){
if ($s==0) return 1;
else return $fact = $s [...]
PHP offers a large variety of arguments that can be passed to the date() function. You are able to almost everything you want having just the current time stamp. I’ve selected the most useful readable formats - I think you might need it for any purpose. I used it to randomize a site’s content [...]
When you need to deal with big amounts of data, MySQL is not a good solution. db4 is much faster and easier - you don’t need any SQL queries to extract the necessary values and use them. The process of db4 file creation is quite easy; you need to have your PHP compiled with dba [...]
You can often see it even on popular forums. Google Adsense or any other ad code is inserted between posts or looks like a usual post. How do they do that?
I will show you how to add Adsense code after first post and I hope you will be able to figure out how to do [...]
Recently I had to decode a string that was encoded with javascript, using ascii codes of symbols. In JavaScript everything looks simple - unescape() allows to get a readable string. But I had to do it with PHP and the first thought was to use chr and ord functions. But there was a simple solution [...]
Today I’ll show you the script that allows to get Google Pagerank value for any site you like. Note, that Google limits the number of toolbar queries per IP per day.
<?php
function StrToNum($Str, $Check, $Magic) {
$Int32Unit = 4294967296;
$length = strlen($Str);
for ($i = 0; $i < $length; $i++) {
$Check *= $Magic;
if ($Check >= $Int32Unit) {
$Check = ($Check [...]