Print Less-Than and Greater-Than Symbols in PHP

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



Leave a reply



Submit