How to assign to a variable the initial value of another variable?

Hi,

From the pokemon exercise here Coding Games and Programming Challenges to Code Better

Complete the program that simulates the exchange of cards. The card of the first child and that of the second child are represented by the variables $card1 and $card2 respectively. At the end of the program, the variable $card1 must have the initial value of the variable $card2, and the variable $card2 must have the initial value of the variable $card1

<?php
$carte1 = lireLigne();
$carte2 = lireLigne();
$carte1 = $carte2;
$carte2 = $carte1;

why is this code not working?

to swap data, add a temp variable

@FoxLee I swapped the cards via a new variable $card3 but it still doesn’t work

is lireLigne() the French version of readline() in PHP? I could not find this function in the PHP documentation or anywhere else

<?php

$carte1 = lireLigne();
$carte2 = lireLigne();
$carte3 = $carte1;
$carte1 = $carte2;
$carte2 = $carte3;
echo "carte 1 : ".$carte1." <br> carte 2 : ".$carte2;

$a = readline('a = ');
$b = readline('b = ');

$tmp = $a;
$a = $b;
$b = $tmp;

echo 'a = ’ . $a . ', b = ’ . $b . “\n”;