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);
?>
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 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
$VAR= 5;
$VAR1=30;
Mathematical expression :- 5 * 60 * 60 + 30 * 60
i.e. 5 and 30 are $VAR and $VAR1 respectively.
how to use this manually in php code and store result in $RESULT.
This will work:
$result = $VAR * 60 *60 +$VAR1 *60;
The following link will give you an idea of order of preferance
Here is your expression
<?php
$VAR = 5;
$VAR1 = 30;
$calc = - $VAR * 60 * 60 + $VAR1 * 60;
echo $calc;
?>
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)