PHP - Getting Data Out Of An Array
I need to pull data out of google's merchant API. The resulting array I am getting is confusing me though and I am not sure how to pull the data I need from it. How would I get all the "name" fields out of the array or say product titles? Either to just print to screen or save to another variable? I'm currently pulling the data in the json format. Google offers both json and atom. I figured json would be easier? I thought I could just do something like $result['name'] but that doesn't seem to be working.
Here's my code, and a snippet of the output. Code: [Select] <?php $result = json_decode(file_get_contents('https://www.googleapis.com/shopping/search/v1/public/products?key=key&country=US&q=digital+camera&alt=json'), true); echo "<pre>"; var_dump($result); echo "</pre>"; ?> [code] array(10) { ["kind"]=> string(17) "shopping#products" ["etag"]=> string(57) ""q_Cz93YRTLuwHgwpLYFnNN97DNM/Yat9tcRJVFxzoZmXA_0H3Qp-HuI"" ["id"]=> string(37) "tag:google.com,2010:shopping/products" ["selfLink"]=> string(125) "https://www.googleapis.com/shopping/search/v1/public/products?country=US&q=digital+camera&alt=json&startIndex=1&maxResults=25" ["nextLink"]=> string(126) "https://www.googleapis.com/shopping/search/v1/public/products?country=US&q=digital+camera&alt=json&startIndex=26&maxResults=25" ["totalItems"]=> int(833935) ["startIndex"]=> int(1) ["itemsPerPage"]=> int(25) ["currentItemCount"]=> int(25) ["items"]=> array(25) { [0]=> array(4) { ["kind"]=> string(16) "shopping#product" ["id"]=> string(66) "tag:google.com,2010:shopping/products/1113342/17031817732574057954" ["selfLink"]=> string(103) "https://www.googleapis.com/shopping/search/v1/public/products/1113342/gid/17031817732574057954?alt=json" ["product"]=> array(15) { ["googleId"]=> string(20) "17031817732574057954" ["author"]=> array(2) { ["name"]=> string(7) "Walmart" ["accountId"]=> string(7) "1113342" } ["creationTime"]=> string(24) "2011-07-07T18:51:04.000Z" ["modificationTime"]=> string(24) "2011-10-16T21:59:30.000Z" ["country"]=> string(2) "US" ["language"]=> string(2) "en" ["title"]=> string(66) "Canon Powershot Sx30-is Black 14.1mp Digital Camera W/ 35x Optical" ["description"]=> string(187) "Canon PowerShot SX30-IS 14MP Black Digital Camera:14.1 megapixel resolutionDelivers excellent picture quality24-840mm wide-angle zoom lensLets you get up close with the 35x optical zoom2." ["link"]=> string(117) "http://www.walmart.com/ip/Canon-14.1-MP-SX30/14972590?sourceid=1500000000000003142050&ci_src=14110944&ci_sku=14972590" ["brand"]=> string(5) "Canon" ["condition"]=> string(3) "new" ["gtin"]=> string(14) "00013803127348" ["gtins"]=> array(1) { [0]=> string(14) "00013803127348" } ["inventories"]=> array(1) { [0]=> array(5) { ["channel"]=> string(6) "online" ["availability"]=> string(7) "inStock" ["price"]=> float(349.99) ["shipping"]=> float(2.97) ["currency"]=> string(3) "USD" } } ["images"]=> array(1) { [0]=> array(1) { ["link"]=> string(71) "http://i.walmartimages.com/i/p/00/01/38/03/12/0001380312734_500X500.jpg" } } } } [1]=> array(4) { ["kind"]=> string(16) "shopping#product" ["id"]=> string(65) "tag:google.com,2010:shopping/products/3622330/1688520904457034451" ["selfLink"]=> string(102) "https://www.googleapis.com/shopping/search/v1/public/products/3622330/gid/1688520904457034451?alt=json" ["product"]=> array(15) { ["googleId"]=> string(19) "1688520904457034451" ["author"]=> array(2) { ["name"]=> string(11) "Apple Store" ["accountId"]=> string(7) "3622330" } ["creationTime"]=> string(24) "2010-10-21T20:31:02.000Z" ["modificationTime"]=> string(24) "2011-10-14T21:10:06.000Z" ["country"]=> string(2) "US" ["language"]=> string(2) "en" ["title"]=> string(39) "Canon PowerShot SX130 IS Digital Camera" ["description"]=> string(532) "Record In Stereo Sound, Then Play Back Your Videos Instantly On You Computer. The Sx130 Is Is All About Creativity, With Fun New Scene Modes Like Miniature Effect For Movies, And Fisheye Effect For Artistically Distorted Stills. While You're Having Fun Creating, The Camera's Smart Flash Exposure And Advanced Smart Auto Systems Are Ensuring That Every Image Is The Best It Can Be. Add The Digic 4 Image Processor, 12.1 Megapixels And Canon's Optical Image Stabilizer, And You've Got The Ideal Camera For Making The Good Times Last." ["link"]=> string(112) "http://store.apple.com/us/go/product/H2807ZM/A?aosid=p228&affiliateID=10262&cid=AOS-US-SHOPIP-Google&site=Google" ["brand"]=> string(5) "Canon" ["condition"]=> string(3) "new" ["gtin"]=> string(14) "00013803127386" ["gtins"]=> array(1) { [0]=> string(14) "00013803127386" } ["inventories"]=> array(1) { [0]=> array(4) { ["channel"]=> string(6) "online" ["availability"]=> string(7) "inStock" ["price"]=> float(229.95) ["currency"]=> string(3) "USD" } } ["images"]=> array(1) { [0]=> array(1) { ["link"]=> string(177) "http://storeimages.apple.com/1819/as-images.apple.com/is/image/AppleInc/H2807?wid=600&hei=600&fmt=jpeg&qlt=95&op_sharpen=0&resMode=bicub&op_usm=0.5,0.5,0,0&iccEmbed=0&layer=comp" } } } } [2]=> array(4) { ["kind"]=> string(16) "shopping#product" ["id"]=> string(66) "tag:google.com,2010:shopping/products/1113342/13850367466326274615" ["selfLink"]=> string(103) "https://www.googleapis.com/shopping/search/v1/public/products/1113342/gid/13850367466326274615?alt=json" ["product"]=> array(15) { ["googleId"]=> string(20) "13850367466326274615" ["author"]=> array(2) { ["name"]=> string(7) "Walmart" ["accountId"]=> string(7) "1113342" } ["creationTime"]=> string(24) "2011-07-04T19:48:28.000Z" ["modificationTime"]=> string(24) "2011-10-16T21:59:30.000Z" ["country"]=> string(2) "US" ["language"]=> string(2) "en" ["title"]=> string(67) "Canon Powershot Sx130-is Black 12.1mp Digital Camera W/ 12x Optical" ["description"]=> string(599) "Canon PowerShot SX130-IS 12.1MP Digital Camera:12.1-megapixel resolutionDelivers excellent picture qualityWide-angle zoom lensLets you get up close with the 12x optical zoom3.0" widescreen LCD displayEnjoy easy focus selection and photo viewingShoot HD videoRecord movies in 720p HD format on the Canon black 12.1MP digital cameraSmart Flash Exposure PowerShot SX130-IS determines the correct flashUseful new scene modesMiniature Effect for movies and Fisheye for capturing imagesSmart AutoSelects the proper settings based on 28 predefined shooting situationsMulti-format memory slotCanon black 12." ["link"]=> string(219) "http://www.walmart.com/ip/Kodak-Playsport-Video-Camera-Value-Bundle-w-Bonus-4GB-Memory-Card-Camera-Yellow-Float-Strap-Rechargeable-Battery-Charger/14972582?sourceid=1500000000000003142050&ci_src=14110944&ci_sku=14972582" ["brand"]=> string(5) "Canon" ["condition"]=> string(3) "new" ["gtin"]=> string(14) "00013803127386" ["gtins"]=> array(1) { [0]=> string(14) "00013803127386" } ["inventories"]=> array(1) { [0]=> array(5) { ["channel"]=> string(6) "online" ["availability"]=> string(7) "inStock" ["price"]=> float(179.99) ["shipping"]=> float(2.97) ["currency"]=> string(3) "USD" } Similar TutorialsI'm creating a tool for building project proposals for clients, with pricing. I have a database with two tables: services and clients. The services table looks like this: Code: [Select] | code | name | cost | +-------------+-------------+------+ | logo_design | Logo design | 10 | | web_design | Web design | 20 | The clients table looks like this: Code: [Select] | id | client | logo_design | web_design | +----+---------+-------------+------------+ | 1 | Walrus | yes | yes | | 2 | Narwhal | no | yes | How would I link the results from these two tables so that I only pull out the services each person wants from the database? Here is what I have so far: Code: [Select] <? $sql = "SELECT * FROM services"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo $row{'name'} . ': $' . $row{'cost'} . '<br />'; } ?> This, of course, displays all the services, with all the prices, like so: Logo design: $10 Web design: $20 I want to add something here so that based on the selected client, we see only the services/prices they selected (ol' Narwhal's page would not show the "Logo Design" line). I've got the data from "clients" pulled in to this page as well, but don't know how to relate it to "services." Thanks in advance! Let me know if I've left out any info that would help you to point me in the right direction. Hi, after banging my head against the wall for a while thinking this would be a simple task, I'm discovering that this is more complicated than I thought. Basically what I have is a link table linking together source_id and subject_id. For each subject there are multiple sources associated with each. I had created a basic listing of sources by subject... no problem. I now need a way of having a form to create an ordered list in a user-specified way. In other words, I can currently order by id or alphabetically (subject name lives on a different table), but I need the option of choosing the order in which they display. I added another row to this table called order_by. No problem again, and I can manage all of this in the database, however I want to create a basic form where I can view sources by subject and then enter a number that I can use for sorting. I started off looping through each of the entries and the database (with a where), and creating a foreach like so (with the subject_id being grabbed via GET from the URL on a previous script) Code: [Select] while($row = mysqli_fetch_array($rs)) { //update row order if (isset($_POST['submit'])) { //get variables, and assign order $subject_id = $_GET['subject_id']; $order_by = $_POST['order_by']; $source_id = $row['source_id']; //echo 'Order by entered as ' . $order_by . '<br />'; foreach ($_POST['order_by'] as $order_by) { $qorder = "UPDATE source_subject set order_by = '$order_by' WHERE source_id = '$source_id' AND subject_id = '$subject_id'"; mysqli_query($dbc, $qorder) or die ('could not insert order'); // echo $subject_id . ', ' . $order_by . ', ' . $source_id; // echo '<br />'; } } else { $subject_id = $_GET['subject_id']; $order_by = $row['order_by']; $source_id = $row['source_id']; } And have the line in the form like so: Code: [Select] echo '<input type="text" id="order_by" name="order_by[]" size="1" value="'. $order_by .'"/> (yes I know I didn't escape the input field... it's all stored in an htaccess protected directory; I will clean it up later once I get it to work) This, of course, results in every source_id getting the same "order_by" no matter what I put into each field. I'm thinking that I need to do some sort of foreach where I go through foreach source_id and have it update the "order_by" field for each one, but I must admit I'm not sure how to go about this (the flaws of being self-taught I suppose; I don't have anyone to go to on this). I'm hoping someone here can help? Thanks a ton in advance hi i am trying to make a payroll calculator script that takes employee info, calculates pay, displays submitted info in a table, stores info in an array, and updates the array when new info is submitted. i have most of these accomplished, i am having trouble with the "store into an array, and update the array when new info is submitted" parts of the project. i am still not very fluent in php so there may be easier ways to achieve what i have so far. any pointers would be a great help, this part has got me stumped. Using curl_multi, I have loaded up 3 url's and then printed the array. 1) How can I also set a timestamp on output to let me know when each url was run? 2) How can I explode the array to only display the data and timestamp, excluding the text "Array ( =>", "[1] =>", "[2] =>" and " )"? Code <?php function multiRequest($data, $options = array()) { // array of curl handles $curly = array(); // data to be returned $result = array(); // multi handle $mh = curl_multi_init(); // loop through $data and create curl handles // then add them to the multi-handle foreach ($data as $id => $d) { $curly[$id] = curl_init(); $url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d; curl_setopt($curly[$id], CURLOPT_URL, $url); curl_setopt($curly[$id], CURLOPT_HEADER, 0); curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1); // post? if (is_array($d)) { if (!empty($d['post'])) { curl_setopt($curly[$id], CURLOPT_POST, 1); curl_setopt($curly[$id], CURLOPT_POSTFIELDS, $d['post']); } } // extra options? if (!empty($options)) { curl_setopt_array($curly[$id], $options); } curl_multi_add_handle($mh, $curly[$id]); } // execute the handles $running = null; do { curl_multi_exec($mh, $running); } while($running > 0); // get content and remove handles foreach($curly as $id => $c) { $result[$id] = curl_multi_getcontent($c); curl_multi_remove_handle($mh, $c); } // all done curl_multi_close($mh); return $result; } $data = array(array(),array()); $data[0]['url'] = 'http://search.yahooapis.com/VideoSearchService/V1/videoSearch?appid=YahooDemo&query=Pearl+Jam&output=json'; $data[1]['url'] = 'http://search.yahooapis.com/VideoSearchService/V1/videoSearch?appid=YahooDemo&query=Black+Eyed+Peas&output=json'; $data[2]['url'] = 'http://search.yahooapis.com/VideoSearchService/V1/videoSearch?appid=YahooDemo&query=Nirvana&output=json'; $r = multiRequest($data); print_r($r); ?> Output Array ( => Pearl Jam [1] => Black Eyed Peas [2] => Nirvana ) Preferred Output 01:00:01 Pearl Jam 01:00:02 Black Eyed Peas 01:00:03 Nirvana Hello, I have a variable called $Price, We are getting it through Mysql Database using While loop. We getting the data from database in ordered by ID. Now then i have requirement to store that data into Low to High form ... Like we are receiving $price lke unordered form .. 50 14 35 25 00 145 52 Here i just want to store it in Low to high form like 00, 14,25,35 ... and so on .. Please suggest me the appropriate code. While($myrow=mysql_fetch_array($result, MYSQL_ASSOC)) { some codes return value $price. // want to store in array } $array($price) // here want to store in Low to high with key value. Hi,
I'm working on a project and I've run into a problem and I can't seem to figure out how to fix it or even what is wrong no matter how much I google. I have data in an xml file that I need to read and use to create an array.
Here is the XML (food.xml):
<?xml version="1.0" encoding="UTF-8"?> Hello all.. I have here my array results.. does anyone knows how to simplify this array? i would like to get the following value and echo it... Code: [Select] Array ( [GetSMSInboundResponse] => Array ( [Transaction] => Array ( [Code] => 1 [Description] => Transaction OK ) [SMSInbounds] => Array ( [InboundSMS] => Array ( [0] => Array ( [ID] => 3126861 [Originator] => +447537404702 [Destination] => +447537404702 [Keyword] => UCB2 [Date] => 2012-01-24 [Time] => 13:21:45 [Body] => UCB2 this is a "quotes", single quote... Test for receiving a message having commas, double quotes and single quote... ) [1] => Array ( [ID] => 3126867 [Originator] => +447537404702 [Destination] => +447537404702 [Keyword] => UCB2 [Date] => 2012-01-24 [Time] => 13:21:45 [Body] => UCB2 this is a "quotes", single quote... Test for receiving a message having commas, double quotes and single quote 2... ) ) ) ) ) I would like to echo the result on this part of array Code: [Select] [0] => Array ( [ID] => 3126861 [Originator] => +447537404702 [Destination] => +447537404702 [Keyword] => UCB2 [Date] => 2012-01-24 [Time] => 13:21:45 [Body] => UCB2 this is a "quotes", single quote... Test for receiving a message having commas, double quotes and single quote... ) [1] => Array ( [ID] => 3126867 [Originator] => +447537404702 [Destination] => +447537404702 [Keyword] => UCB2 [Date] => 2012-01-24 [Time] => 13:21:45 [Body] => UCB2 this is a "quotes", single quote... Test for receiving a message having commas, double quotes and single quote 2... ) but i have problems on how to do it.. please help me guys.. thanks in advance My aim is to make an enquiry form and its database name is ashish and table name is mydata...everytime i am inserting data and then displaying it on the browser with the use of print_r getting each input data twice...attacthing my code ..help me..thanx in advance this file is form.php <?php include("dbconnect.php"); include("cwfunction.php")?> <form name="form1" action="#" method="post"> Name<input name="stuname" type="text" value=""><br/> Address<input name="address" type="text" value=""><br/> Contact<input name="contact" type="text" value=""><br/> Email<input name="email" type="text" value=""><br/> Internet<input name="how" type="radio" value="internet"><br/> Friend<input name="how" type="radio" value="friend"><br/> Other<input name="how" type="radio" value="other"><br/> <input name="submit" type="submit" value="ENTER"><br/> </form> <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $stuname=$_POST['stuname']; $address=$_POST['address']; $contact=$_POST['contact']; $email=$_POST['email']; $how=$_POST['how']; insert_data($stuname,$address,$contact,$email,$how,$connect); display_data(); echo "<table border=1>"; echo "<tr>"; echo "<td>Sr.No</td>"; echo "<td>Student Name</td>"; echo "<td>Address</td>"; echo "<td>Contact no</td>"; echo "<td>email</td>"; echo "<td>how</td>"; echo "<td>edit</td>"; echo "<td>delete</td>"; echo "</tr>"; echo "</table>"; ?> this file is dbconnect.php <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $connect= mysql_connect("localhost","root","") or die("Connection Error". mysql_error()); //echo "connection established"; if(mysql_select_db("ashish",$connect)) { //echo "<br/>database selected"; } ?> this file is cwfunction.php <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ function insert_data($stuname,$address,$contact,$email,$how,$connect) { global $stuname; global $address; global $contact; global $email; global $how; global $connect; $query="INSERT INTO mydata(student_name,address,contact,email,how) VALUES('$stuname','$address','$contact','$email','$how')"; $result=mysql_query($query,$connect); } function display_data() { echo "i m in display data"; $query="SELECT * FROM mydata"; $result=mysql_query($query); $row = mysql_fetch_array($result); print_r($row); // if($result) // { // $arr = array(); // while($row = mysql_fetch_array($result)) // { // array_push($arr,$row); // } // // // // } //return $arr; } I have the current data show up when I do a var_dump. Code: [Select] Code $result = $wrap->get_lists(); echo "Result of lists:<br />"; if($result->was_successful()) { echo "Got lists\n<br /><pre>"; var_dump($result->response); //print_r($result->response); } else { echo 'Failed with code '.$result->http_status_code."\n<br /><pre>"; var_dump($result->response); } echo '</pre>'; Data Output array(303) { [0]=> object(stdClass)#5 (2) { ["ListID"]=> string(32) "df2d1497b0f4bdc3b8b77863f6721025" ["Name"]=> string(14) "DATA1" } [1]=> object(stdClass)#6 (2) { ["ListID"]=> string(32) "f44d9acf655e914b944d7174bdd521ff" ["Name"]=> string(14) "DATA2" } [2]=> object(stdClass)#7 (2) { ["ListID"]=> string(32) "c84f4ba6b86bc508e6922f4ca44ab41c" ["Name"]=> string(14) "DATA3" } [3]=> object(stdClass)#8 (2) { ["ListID"]=> string(32) "b7dc652cd5060194362f19667ddf47e9" ["Name"]=> string(14) "DATA4" } } What I need to achieve is get the data in "ListID" out so I can run "ListID" through another function of mine, to delete records. Any ideas, how I would get "ListID" values out of the array? hi, Im getting data from a database and store in an array. and there will be a lot of repeating data in the array. I would like to know if there is any function can filter the array and arrange in a nice position. or there's no way doing it and need to check it manually? appreciate for the help. thanks. Hello All, First, I'm new to php and I have spent a lot of time searching forums and google for the answer to my question with no luck, so if it's a topic already covered, PLEASE reply with a link or point me in the right direction. OK, I have a form that let's users upload multiple images. The upload portion works fine. What I can't figure out how to do is put the image name of each file that gets uploaded all into the same table record. I also need each file name to be put into it's own column in the table. For example, file1, file2 and file3 will get dumped into the same record and into it's respective column (uploaded_image1, uploaded_image2, uploaded_image3). I've included the working upload code and the code that inserts some of the information into the database (just not the image names). Code: [Select] echo "<textarea name=challenge rows=15 cols=60> </textarea><br/><br/>" echo "<textarea name=insight rows=15 cols=60> </textarea><br/><br/>" for($i=1; $i<=$max_no_img; $i++){ echo "Image $i <input type=file name='image[]' ><br/>"; } echo "<input type=submit value=Submit>"; Code: [Select] // Connect to DB $host = 'xxx'; $user = 'xxx'; $pass = 'xxx'; $db = 'xxx'; mysql_connect($host,$user,$pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); // Post Variables $challenge = $_POST['challenge']; $insight = $_POST['insight']; $filename=serialize($_POST['filename']); // Upload Images while(list($key,$value) = each($_FILES[image][name])) { if(!empty($value)) { $filename = $value; $add = "upimage/$filename"; copy($_FILES[image][tmp_name][$key], $add); chmod("$add",0777); } } // Insert into database $query = "INSERT INTO table ( challenge, insight, uploaded_image1, uploaded_image2, uploaded_image3,)". "values ( '$challenge', '$insight', '$filename' '$filename2' '$filename3')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); I know just enough about php that the reason the above wont work, is because $filename2 and $filename3 haven't been given a value. Unfortunately, I have no idea how to separate that information in the array. If anyone can point me in the right direction I'd be forever grateful! Thanks, Gary I am in the process of writing code for a dynamic form. I have the part of the form written for information to be entered. I am now trying to write code for the modification of the information in the table. I know that I want to get the table data my doing a MySql Select and putting that information into an array. I am not very familiar with arrays and have spent some time looking for a solution online with no solution. When I print_r the results I get what I want but when I do anything else I get Array. What I am actually looking to do is make it so that the table data is in another variable this is the section of code that I am working with. Code: [Select] $mod_form = "<form name='insert_table' id='insert_table' action='ad_add.php' method='post' enctype='multipart/form-data'> <fieldset> <legend>table information</legend> <input name='table' TYPE='hidden' VALUE='" . $table . "' />"; $mod_sql = "SELECT * FROM $table WHERE id = '$id'"; $mod_sql_result = mysql_query($mod_sql); $allowed_ext = array('jpg', 'jpeg', 'png', 'gif'); $input_array = array(); while ($row = mysql_fetch_array($mod_sql_result, MYSQL_NUM)) { $input_array[] = $row; } foreach ($input_array as $input => $data) { print_r($data); } while ($i < mysql_num_fields($mod_sql_result)) { $header = str_replace("_", " ", (mysql_field_name($mod_sql_result, $i))); $name = mysql_field_name($mod_sql_result, $i); (mysql_field_name($mod_sql_result, $i) == 'image' ? $mod_form .= "<p>" . $header . ": <input name='" . $name . "' id='" . $name . "' type='file' /></p>" : $mod_form .= "<p>" . $header . ": <input name='" . $name . "' id='" . $name . "' type='text' value='" . $input . "'/></p>"); $i++; } $mod_form .= " <p> <input type='submit' name='submit_mod' id='submit_mod' /> </p> </fieldset> </form> "; echo $mod_form; Hi guys, This is my problem: I have a csv file let's say have these values: blue,1,2,3,4 red,8,5,6,7 I need to add thes values into a 2d array to be able to use like this: colors[1][2]=2 colors[2][4]=7 Where my first number is the row and the second number is the value within that row. This is what I got so far <?PHP $i=0; $j=0; $file_handle = fopen("color-list.csv", "r"); while (!feof($file_handle) ) { $colors = fgetcsv($file_handle, 10000); for ($j=0; $j<=4; $j++) { $row[$i][$j]=$colors[$j]; print row[$i][$j]; } $i++; ?> For some reason this doesn't work. Maybe I am declaring the arrays wrong. Thank you! Hi everyone, Hope someone can help. Does anyone know why this is nor displaying any data? Code: [Select] $qry = mysql_query("select * from product"); $data = array(); while($row = mysql_fetch_array($qry)){ $productName[] =$row['productName']; // Item name } for($i=0;$i<mysql_num_rows($row);$i++) { $data = $productName[$i]; } return $data; Thanks in advance Edd What I need is to: - take the information from array 1 - remove it from array 2 - then ADD it OR take from array 3 (this of course depends on array 1) I also have to keep in mind that array 1 could be empty thus needing to empty array 2 and IF the information is in array 3 then remove it array 3 is the main array that I will update the database row which will in turn display the correct check boxes checked or not Thank you for reading, I hope you can help me. Code: [Select] Array //#1 this is the submitted information ( [0] => 103100000 [1] => 103200000 [2] => 103400000 [3] => 103500000 [4] => 103700000 ) Array //#2 all possible choices ( [0] => 103100000 [1] => 103200000 [2] => 103300000 [3] => 103400000 [4] => 103500000 [5] => 103600000 [6] => 103700000 ) Array //#3 currently stored in database / marks the check boxes "checked" ( [0] => 103100000 [1] => 103200000 [2] => 103300000 [3] => 103400000 [4] => 103500000 [5] => 103600000 [6] => 103700000 ) Hi - I have an array where one of the values delivers a string. Here is the output from a print_r($pickupdates): Code: [Select] Array ( [0] => Array ( [location] => Clearwater [TheDates] => 1311746700,1321746641,1331668779 ) [1] => Array ( [location] => Canmore [TheDates] => 1311746700,1321746641,1331746641 ) [2] => Array ( [location] => Collingwood [TheDates] => 1311746700,1321746641,1331746641 ) [3] => Array ( [location] => Varsity [TheDates] => 1321746641,1330746700,1331746700 ) The challenge is to get the location and TheDates into a nice HTML table which would look like this: Code: [Select] LOCATION DATE 1 DATE 2 DATE 3 Clearwater April 1 May 1 June 1 Varsity April 2 May 2 June 2 Collingwood April 3 May 3 June 3 Canmore April 4 May 4 June 4 Ok - Now I am stuck, I need to be able to uniquely identify each date that is associated with the location such that I can run a foreach() on then so I can populate the table properly. I tried using list() and explode. List does not separate the dates and explode needs a string not an array. I'm really stuck - a very big Heartfelt thanks to anyone who can steer me in the right direction. MANY THANKS ! I am having problems displaying individual data I am using $filename[0] to display the first data, any ideas where i am going wrong. <?php $active_keys = array(); foreach($_POST['img'] as $key => $filename) { if(!empty($filename)) { $active_keys[] = $key; } echo "". $filename[1]; } ?> Hello every body i have a array like this
Array ( [19/5/14] => Array ( [94-DE-80-28-CF-BC] => Array ( [7] => Array ( [qax] => 1 ) ) } }I want to add new array under the [94-DE-80-28-CF-BC] => Array.. I am doing code but what it does it overrides the full array inside that array and create a new one... The code i've used is | array_push( $vis[$date][$macp], array( "$id"=>array( "$country"=>1 ) )); |