Syntax:DsSet public DsSet::reversed (void)
Parameter: this function takes no parameters.Return value:this function returns a back copy of the actual instance of Set.The following programs illustrate the Ds / function Set::reversed() :Program 1:
// Declare an empty set
$set
=
new
DsSet ([1, 2, 3, 4, 5]);
// Print an inverted copy
echo
(
"Reversed Set is:"
);
print_r (
$set
-> reversed());
// The actual set remains unchanged
echo
"Actual Set is:"
;
print_r (
$set
);
?>
Exit:Reversed Set is : DsSet Object ([0] = > 5 [1] = > 4 [2] = > 3 [3] = > 2 [4] = > 1) Actual Set is: DsSet Object ([0] = > 1 [1] = > 2 [2] = > 3 [3] = > 4 [4] = > 5)
Program 2:
// Declare an empty set
$set
=
new
DsSet ([
"Welcome"
,
" 2 "
,
" Geeks "
]);
// Print an inverted copy
echo
(
"Reversed Set is:"
);
print_r (
$set
-> reversed());
// The actual set remains unchanged
echo
"Actual Set is:"
;
print_r (
$set
);
?>
Exit:Reversed Set is : DsSet Object ([0] = > Geeks [1] = > 2 [2] = > Welcome) Actual Set is: DsSet Object ([0] = > Welcome [1] = > 2 [2] = > Geeks)
Link: http: // php .net / manual / en / ds-set.reversed.php