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
Related
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
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 5 years ago.
Improve this question
function inchesTodecimal($inches){
return $decimal=inches/12;
}
I want convert inches to decimal like 11=0.917. I want to save 11 inches in database like decimal number 0.917.there is a problem occur when inches is 10.In float type .10=1
First you convert your feet Inches in to feet decimal like 5 feet and after point value convert it into decimal like 11=9.17 then insert into your database. When you want to show on user end you convert again feet Decimal to feet Inches like 5.917=>5.11 its simple hope you got what you want...
Here my simple code for conversion:
function feetInchesToDecimal($feetinches,$precision = 3){
list($feet,$inches) = explode(".",$feetinches);
$inches = preg_replace('/[^0-9.]/','',$inches);
$inches = $inches + ($feet * 12);
return round($inches /12,$precision);
}
function feetDecimalToInchs($feetdecimal){
$feet=(int)$feetdecimal;
$inches=round(($feetdecimal-$feet)*12);
$feetinches=$feet;
if($inches>0) $feetinches.=".".$inches;
return $feetinches;
}
echo feetInchesToDecimal(5.11); //5.917
echo feetDecimalToInchs(5.917); //5.11
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 would like to know how can I change
$var = "01:30:00";
to
$var = "1.5";
in PHP ?
Thanks.
Something along these lines...
<?php
function timeToHours($time) {
$hoursMinsSecs = explode(':', $time);
return $hoursMinsSecs[0] + $hoursMinsSecs[1] / 60 + $hoursMinsSecs[2] / 3600;
}
$var = "01:30:00";
echo timeToHours($var);
?>