How to get a third variable from a merge of two variables in php

Asked

Viewed 31 times

0

all right? i’m having the following problem getting a variable in php follows the code:

<?php
$video1="welcome.mp4";
$video2="movie.mp4";
$video3="ends.mp4";

$num_id="1";
$get = '$' . "video" . $num_id; 
$file = $get;
echo "<a href=Player.php?file=$file'>Play</a>";
?>

but when I see the result in html the gross variable $video1 appears but I want the result as: Welcome.mp4

HTML Result:

<a href="player.php?file=$video1">Play</a>

HTML - Expectation:

<a href="player.php?file=welcome.mp4">Play</a>
  • sorry, I hadn’t noticed. I edited the video variables 1, Video2, video3 adding $ but still the case is the same

  • Try the following echo "<a href=Player.php?file=" . $file . ">Play</a>";. Use this contact, so it will put the right value on the variable, before going to view.

  • did not work. result is: . video .

  • 1

    What you want to do is $file = ${$get}, but I see no point in creating that extra variable.

  • exactly what I needed really didn’t need this variable "$file" the more was in search to make it work that way with ${$video1} will be perfect in my code now. Thank you all, really.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.