print all array string if index is less than something
You can do it with implode() and array_slice() like below:-
$input = array("a", "b", "c", "d", "e");
$output = implode("/",array_slice($input,0, 3));
echo $output;
Output:- https://eval.in/887209
Note:- if you array is not sorted and then also you want a/b/c
then use sort() function like below:-
https://eval.in/887231
PHP : No readable output, when I use the less than symbol, in combination with the var_dump() function
It's seems that you dump this var in html file and browser parse this:
"<Hello World!"
as
<hello world!"="" <="" body="">
</hello>
This snippet
$string = ">Hello World!"
can't be parsed as html tag, so you can get readable output.
PHP - Greater than but less than function
$set = isset($rdata['Password last set']);
$delta = (time() - (strtotime($rdata['Password last set'])) / $day;
if ($set)
if ($delta >= 730)
echo "red";
elseif ($delta >= 180)
echo "yellow";
else
; // otherwise the next "else" will be for "if ($delta)" and not "if ($set)"
else
echo "<td></td>";
or much better
if ($set)
{
if ($delta >= 730)
echo "red";
elseif ($delta >= 180)
echo "yellow";
}
else
{
echo "<td></td>";
}
or
if ($set):
if ($delta >= 730):
echo "red";
elseif ($delta >= 180):
echo "yellow";
endif;
else:
echo "<td></td>";
endif;
I would recommend to use { }
or :
always except maybe when the expression under if
occupies one line.
Related Topics
How to Create a New Joomla User Account from Within a Script
Differencebetween Null and Empty
Message: Trying to Access Array Offset on Value of Type Null
PHP Curl Get Request and Request's Body
What Is 22527 in Error_Reporting 22527 of PHPinfo
Get Start and End Days for a Given Week in PHP
How to Get the Last Path in a Url
PHP & MySQL: When Exactly to Use HTMLentities
PHP - How to Implement Password Reset and Token Expiry
Php: Catch Exception and Continue Execution, Is It Possible
Laravel Cannot Delete or Update a Parent Row: a Foreign Key Constraint Fails
Syntax Error, Unexpected T_Encapsed_And_Whitespace, Expecting T_String or T_Variable or T_Num_String
Laravel and View Caching in Development -- Can't See Changes Right Away