Closed Thread
Thread Tools Search this Thread
Unread 30th Jan 2015, 02:29 PM   #1
HyperActive Warrior
 
shubham's Avatar
 
Join Date: 2010
Location: India
Posts: 159
Thanks: 7
Thanked 1 Time in 1 Post
Default
RE: php array
Share on: 
fb share twitter share gplus share more share

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

?>
shubham is offline  
Unread 30th Jan 2015, 02:43 PM   #2
Warrior Member
 
Join Date: 2015
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: php array
Share on: 
fb share twitter share gplus share more share

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 .
rmcnew is offline  
Unread 30th Jan 2015, 02:47 PM   #3
HyperActive Warrior
 
shubham's Avatar
 
Join Date: 2010
Location: India
Posts: 159
Thanks: 7
Thanked 1 Time in 1 Post
Default
Re: php array
Share on: 
fb share twitter share gplus share more share

Hi there ,
please add me in your skype (shubham.raj3)
.
shubham is offline  
Unread 30th Jan 2015, 03:00 PM   #4
Warrior Member
 
Join Date: 2015
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: php array
Share on: 
fb share twitter share gplus share more share

Originally Posted by shubham View Post

Hi there ,
please add me in your skype (shubham.raj3)
.
Already Done.
rmcnew is offline  
The Following User Says Thank You to rmcnew For This Useful Post:
Unread 3rd Feb 2015, 10:36 AM   #5
DATASTYLING - Book Design
War Room Member
 
Join Date: 2011
Location: Cebu Philippines
Posts: 32
Thanks: 0
Thanked 3 Times in 3 Posts
Default
Re: php array
Share on: 
fb share twitter share gplus share more share

try using json via xml.

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
datastyling is offline  
Closed Thread


Bookmarks

Tags
array, php

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 12:11 AM.