10/12/2012

array_diff not support ojbect

array_diff for parameters does not support objects


e.g.
$a = array(
   'a',
   'b',
);
$b = array(
   'b',
   'c'
);

$c = array_diff($a, $b);

$c = array(1=>'b');

------------------------------

for object, 

$a = array(
   new stdClass(),
   'b',
);
$b = array(
   'b',
   'c'
);

$c = array_diff($a, $b);

you will get error message
Catchable fatal error: Object of class stdClass could not be converted to string in...............

multi-language setting gettext for php

The following code creates multiple language site based on gettext from PHP.

Language:
English and Japanese
English:  Hello
Japanese: こんにちは

Step 1:  Get supported language from client

Method 1, auto-detect
<?php
$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if ($language == 'ja') {
    $language = 'ja_JP';
}else{
    $language = 'en_US';
}
?>

Method 2, $_GET-detect
<?php
$language = $_REQUEST ['lan'];
if ($language == 'ja') {
    $language = 'ja_JP';
}else{
    $language = 'en_US';
}
?>


Step 2:  Set locale and default domain
<?php
putenv("LANG=$language");
setlocale(LC_ALL, $language);
$domain = 'domain_file_name';
bindtextdomain($domain, "/var/www/html/locale");
textdomain($domain);
?>

Step 3:  Output
Method 1, 
<?php
echo _('Hello');
?>
Method 1,
<?php
echo gettext('Hello');
?>

Now you may save all codes above with one php file with any name, here I use index.php, which looks like
 ------------------index.php--------------------------------
 
<?php
$language = $_REQUEST ['lan'];
if ($language == 'ja') {
    $language = 'ja_JP';
}else{
    $language = 'en_US';
}

putenv("LANG=$language");
setlocale(LC_ALL, $language);
$domain = 'domain_file_name';
bindtextdomain($domain, "/var/www/html/locale");
textdomain($domain);

echo _('Hello');
?>
 -------------------------------------------

Step 4:   Create po file based on $domain setting, the command looks like

xgettext -d domain_file_name index.php --from-code=utf-8

After executing the command, you may get one new file, whose name is 'domain_file_name.po'. Open it
-------------------------domain_file_name.po------------------------------
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR , YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-10-12 14:41+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: index.php:16
msgid "Hello"
msgstr ""


---------------------------------------------------------

Then you may change 
1.  charset=CHARSET  -> charset=utf-8
2. msgstr "" -> msgstr="こんにちは"

------------------------------------------------------------


Step 5:   Create mo file based on domain_file_name.po, the command looks like
 msgfmt domain_file_name.po 

Now you have created one file, whose name is  domain_file_name.mo

Step 6:  Move domain_file_name.mo to special directory like


locale
       /en_US
                 /LC_MESSAGES
                                          / domain_file_name.mo
      /ja_JP
                 /LC_MESSAGES
                                          / domain_file_name.mo


Now you may access the index.php from your browser by 

index.php?lan=ja_JP or index.php

and you may get different message. 










2/22/2011

Burst Traffic – CPM Network for New Blogs

Before going with Burst Traffic review, I would like to describe my reader, what is a CPM network, as this is the first blog entry in Money9 related to CPM network.

What is a CPM network?

Well, according to Wikipedia “CPM is frequently used in advertising to represent cost per thousand (where M is the roman numeral of 1000). When used in online advertising it relates to the cost per thousand page impressions.”
For example, say a website has 20,000 daily page views and the eCPM value for that website is $1. Then the website makes $20 per day. Where eCPM is the amount shared to website admins for per thousand page views.

Why use CPM ads?

CPM ads are perfect for those website/blogs which have low ad click and high page views. It is not necessary that if you have high page views then you must have high CTR (Click Through Rate). So, if your blog is new but it has high page views then you can try CPM networks. For example, say your blog has 2000 page views per day but your users’ clicks on ads 2~3 times daily. Then you will earn around $0.50 roughly. But if you use CPM network then for those 2000 page views you can earn $1 for an eCPM at $0.50 Hence, CPM networks fit those blogs/websites which has huge page views.

List of CPM Networks:

Casale Media
Burst Media
Value Click
Tribal Fusion
Right Media

But all these networks required a huge page views per month, but if your blog is new then you must try Brust Traffic Network.

Burst Traffic Review:

burst-traffic-logoBurst Traffic is similar as other CPM networks with a great eCPM value. Without displaying direct advertisements, bt network also serves ads from their partner networks like Google Adsense. You will be paid only for impressions. Usually their eCPM for per 1000 page views in US related countries is $0.30~0.60 or more. But if your website traffic is coming from rest of the world then your eCPM can fluctuate with your traffic at a rate of $0.05~0.60 etc. But remember this is not the actual value of their eCPM because eCPM changes every time with your traffic’s geographical location.

Why Burst Traffic?

Brand Safe inventory
Attractive eCPM and high fill rates
Reliable reporting and ad serving
Clean advertisements
Prompt payments with no minimum weekly payout ( every Friday )
Fidelity
Realtime reporting

Also, bt works by purchasing traffic on a 70/30 revenue share basis and their goal is to provide publishers with a solution that increases the income of their sites by giving you the ability to increase fill rates and as a result, increase your overall eCPM.

Advertisement Size:

Tiny windowed ads
728×90 Leaderboard
160×600 Skyscraper
300×250 Medium Rectangle

Payment Information:

Now this is the most interesting part of Burst Traffic Network that they doesn’t have any minimum payout. Usually BT network pays each Friday (approximately 5 PM IST GMT +5.30) so, you do not have to wait for payments! In this case, let me tell you a story – When I have started displaying BT Network ads it was Thursday evening and on Friday I got 2 cents! LoL! :DNever mind, but you can earn lot of money from here!

Get A Burst Traffic Network Now!