4 replies
Hello everyone,

I am trying to use Multidimensional arrays for sending data to another page but i am not able to retrive data of paths (individual),but i am able to access all the data at a time when i use print_r function .
what i want to do :
i am trying to send the data (using array) form my video_array.php to sh.php for showing the list of videos
which is present in the folder and when user click on any video then it play that vvideo.
i am using array so that i can bulid my web page much more dynamic..
please help me ..

thanks shubham..
code :
video_array.php
<?php
//$paths = array();
$videos = array();
$videos["101"] = array(
"name" => "Engineering Mathenatics-III",
"paths" => array(
1010 => "3_sem/video/plcc/a1.mp4",
1011 => "3_sem/video/plcc/a2.mp4",
1012 => "3_sem/video/plcc/a3.mp4",
//1013 => "3_sem/video/plcc/DG-L-4.mov",
//1014 => "3_sem/video/plcc/DG-L-5.mov",
//1015 => "3_sem/video/plcc/DG-L-6.mov",
//1016 => "3_sem/video/plcc/DG-L-7.mov",
//1017 => "3_sem/video/plcc/DG-L-8.mov",
),
);
$videos["102"] = array(
"name" => "Programming Language Concepts and Constructs",
"paths" => array(
1020 => "3_sem/video/plcc/DG-L-1.mov",
1021 => "3_sem/video/plcc/DG-L-2.mov",
1022 => "3_sem/video/plcc/DG-L-3.mov",
1023 => "3_sem/video/plcc/DG-L-4.mov",

),
);
?>
sh.php
<?php
include("include/video_array.php");
include("include/list_array.php");
$subject_id = $_GET["id"];
$subject = $subjects[$subject_id];
$name = $subject["name"];
$type = $subject["type"];
$code = $subject["code"];
$t_credits = $subject["t_credits"];

$video_id = $_GET["id"];
//$path_id = $_GET["id"];
$video = $videos[$video_id];
$v_name = $video["name"];
$path = $video["paths"]
//$paths = $video[$video_id];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $name; ?></title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="main">
<header>
<h1><?php echo "$name<br />" . "Paper type: $type<br />" . "Subject code: $code<br />" . "Totle Credits: $t_credits"; ?>

</h1>
</header>
<div id="video_box">
<h2>Videos</h2>
<div id="video_tab">
<a href="#"><img src="image/video1.png"></a>
</div>
</div>

<div id="pdf">
<h2>PDF</h2>
</div>
</div>

<?php
//foreach ($videos[paths] as $path) {
//echo $path "<br />";
//}
?>
<pre>
<?php
// echo $subject_id . "\n";
// var_dump($subject);

//echo $video_id . "\n";
//var_dump($video);
?>
</pre>

</body>
<?php

?>
#array #php
  • Profile picture of the author rmcnew
    It looks sloppy and inefficient (from a programmers point of view), but one of the most simple and easiest ways to retrieve data from the array tree is to do multiple loops(as foreach) such as "foreach($one as $two){foreach($two as $three){print $three; } }." Just put multiple foreach inside themselves like that until it outputs the info you want. You can save the info into another array you have created by using array_push() maybe. Otherwise, you'll have to mess with doing some more complicated things to output your array using "=>" which is more efficient, but not beginner friendly .
    {{ DiscussionBoard.errors[9848828].message }}
  • Profile picture of the author shubham
    Hi there ,
    please add me in your skype (shubham.raj3)
    .
    {{ DiscussionBoard.errors[9848838].message }}
    • Profile picture of the author rmcnew
      Originally Posted by shubham View Post

      Hi there ,
      please add me in your skype (shubham.raj3)
      .
      Already Done.
      {{ DiscussionBoard.errors[9848863].message }}
  • Profile picture of the author datastyling
    try using json via xml.
    Signature

    BOOK DESIGN & LAYOUT / WEB DEVELOPMENT
    WEBSITE: www.datastyling.com (book design & layout - $95 only) www.thorhosting.co (hosting with free fully functional website) www.infoph.com (open internet directory, jobs, classifieds & news)
    SKYPE: datastyling
    FACEBOOK: https://www.facebook.com/bookdesignservices

    {{ DiscussionBoard.errors[9856987].message }}

Trending Topics