PHP Ds/Stack Copy() Functie

| | | | | | |
Syntaxis:
DsStack public DsStack::copy (void)
Parameters: voor deze functie zijn geen parameters nodig.Retourwaarde:< /b>Deze functie retourneert een ondiepe kopie van de originele stapel. De volgende programma`s illustreren de Ds / Stack-functie::copy() :Programma 1 :
// PHP-illustratieprogramma
// copy() functie
/ / Maak een stack-instantie$stack = new DsStack();
// Duw items op de stapel$stack -> push ( " Welkom" ); $stack -> push ( "to" ); $stack -> push ( "GfG" );
// Gekopieerde stapel afdrukkenprint_r ( $stack -> kopie ());
?>
Afsluiten :
DsStack-object ([ 0] = > GfG [1] = > tot [2] = > Welkom)
Programma 2 :
// PHP-illustratieprogramma
// copy() functie
// Maak een stack-instantie$stack = new DsStack();
// Zet elementen met gemengde waarden ​​op de stapel $stack -> push ( "Welkom" ); $stack -> push ( "naar" ); $stack -> push ( "GfG" ); $stack -> push (10); $stack -> push (5.5);
// Gekopieerde stapel afdrukkenprint_r ( $stack -> kopie ());
?>
Afsluiten :
DsStack Object ([0] = > 5,5 [1] = > 10 [2] = > GfG [3] = > tot [4] = > Welkom)
Link : http: //php.net/manual/en /ds-stack.copy.ph p