Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 days ago.
Improve this question
<?php
$seed = 'COPY_RAFFLE_SEED_HERE'; // Randomly generated seed [Seed:]
$raffle_id = 'COPY_RAFFLE_ID_HERE'; // Raffle ID [Raffle ID:]
$entries = 10; // Number of tickets [Entries count:]
/*
*
* Must +1 return value since it starts with 0
* 28 characters offset to get 4 characters from both hashes
*
*/
$randomNumber = (hexdec(substr(md5($seed) . md5($raffle_id), 28, 8)) % $entries)+1; // Must use +1 as it starts with 0
echo "Ticket with number #$randomNumber won";
apparently this is the code used for the giveaways, and i wanted to see how it works
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I just want to know how to convert inch based on the integer inputted in the field.
For Example:
$int = $_POST['int']; //value 1
//computation here...
$inch = //formula
//echoing the inch
echo $inch;
If you want convert from centimeter can you use this source
function cm2inches($cm)
{
$inches = $cm/2.54;
$inches = $inches%12;
return sprintf('%d ins', $inches);
}
echo cm2inches(162);
You will have result
3 ins
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
These are my strings
2012-13
2013-14
2014-15
2015-16
2016-17
2017-18
I my string is 2014-15 as current financial year, I want my next my next financial year as 2015-16
How can I achieve this with PHP? I get these year list form mysql table, but I want next financial year in php
Try this:
$financial_year = "2012-13";
$fin_array = explode("-", $financial_year);
$next_fin_array[0] = $fin_array[0] + 1;
$next_fin_array[1] = $fin_array[1] + 1;
$next_financial_year = implode("-", $next_fin_array); // Gives 2013-14
Hope this helps.
$myStr = '2014-15';
$yr1 = (int) substr($myStr, 0, 4);
$yr2 = (int) substr($myStr, -2);
echo ($yr1+1).'-'.($yr2+1);
// 2015-16
$financeYear = DateTime::createFromFormat ( "Y-d" ,"2014-15");
$financeYear->modify('+ 1 year');
echo $financeYear->format("Y-d");
Result
2015-15
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to know how I can randomize first and last two digits in php? Suppose the current code is:
FJA793HIYX
then after randomizing it should be:
HJA793HIGD
How can I do that?
Try
$str = 'HJA793HIGD';
$filter = substr($str,1,7);
echo $newstr= randLetter().$filter.randLetter().randLetter();
function randLetter() {
$int = rand(0,26);
$alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$rand_letter = $alpha[$int];
return $rand_letter;
}
Try this!
$randomDigit = substr( "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ,mt_rand( 0 ,34 ) ,1 ) .substr( md5( time() ), 1)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have this a record of: 10/2 * 100%
This is equal to 5
How does it save in PHP?
This not work:
($int1/$int2) * 100
Assuming $int1 = 10 and $int2 = 2, you'd have this sum;
echo (10 / 2) * 1; //1 being 100%
Which outputs 5.
http://codepad.org/twp2TduF
There is nothing wrong - it gives your desired result. I assume you were * 100, which would give 500.
Other percentages
* 0.25 = 25%
* 0.75 = 75%
..and so-on
Or refer to this answer
You cannot use percentage this way.
You will need to divide them by 100:
<?php
$int1 = 3;
$int2 = 6;
echo ($int1/$int2) * 100/100;
this above is 100%
and this:
echo ($int1/$int2) * 25/100;
is 25%
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
I am working on an OSCommerce site, and for the USPS Shipping method I want to convert the weight unit from Pounds to Ounces, but not getting the way how.
Can anyone help?
Given that 1 pound = 16 ounces, you can basically just multiply it by 16:
$pounds = 8;
$ounces = $pounds * 16;
echo $ounces; // 128
...but, if pounds is a float, you will probably want to round it. Since you are talking about shipping weights, you probably want to round up:
$pounds = 8.536;
$ounces = ceil($pounds * 16);
echo $ounces; // 137
You could put this into a function, like this:
function pounds_to_ounces ($pounds) {
return ceil($pounds * 16);
}
echo pounds_to_ounces(8); // 128
echo pounds_to_ounces(8.536); // 137