Print Array Values (simple)
Would anyone know how to print just the values of the array separated by commas? So if I have an array,
$array = ("hello","to","you","there");
I would get
// hello, to, you, there
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Print Form Values
Is it possible to retain the Javascript button but add some php code to print just the values of the form and the input names <input name="Action" onClick="window.print()" type=button value="Print form"> A bit like the email code I have $sEmailFrom = "info@mywebsite.co.uk"; $sEmailTo = "$x_email_1"; $sEmailCc = "$x_email_2" ; $sEmailBcc = "$x_email_3" ; $sEmailSubject = "New instruction"; $message ="Engineer's name: $x_eng_name etc......"; //send email Send_Email($sEmailFrom, $sEmailTo, $sEmailCc, $sEmailBcc, $sEmailSubject, $message);
View Replies !
View Related
Http_post_var To Print Hidden Values
I have a form on page1 that submits to page2. The form contains 2 fields which are name and address. Page2 allows users to go back to page1 or go to page3, so i'm using a function that reads the http_post_var to print hidden values in the page. Here's the code:
View Replies !
View Related
How Do I Get An Ordered List Of Values To Print?
I have a database of my audio CD collection, and I'm trying to get the song titles of each album to print in an ordered list format. Each album is printed in a new table row. For some reason a new row is printed for each song title. Below is part of my script. I included what parts I thought were important. You can see the current output here. The output I want is available here. Notice that the song titles have a number next to them. PHP Code:
View Replies !
View Related
Use Preg_replace To Replace Values In A Template XML File With Values From An Array.
I am trying to use preg_replace to replace values in a template XML file with values from an array using the following: $tmp = preg_replace('/<!-- (S+) -->/ge', $values[1], $line); The template file will have lines such as: <image source="pics/<!-- pic1 -->" thumb="pics/<!-- thumb1 -->" title="<!-- caption1 -->"/> And the $values array has values: $values[pic1] = "raj1.jpg" $values[thumb1] = "traj1.jpg" $values[caption1] = "Who is this?" Can anyone see where I am going wrong?
View Replies !
View Related
Simple Loop To Get Values
i am trying to loop through results in my db, however, i cant get it to work. i need the echo to ouput something with " in it. <?php //Begin of Checking Loop $URLarray = array( parse_str("$QUERY_STRING"); $db = mysql_connect("localhost", "url_tester_user","xxxxx") or die("Could not connect."); if(!$db) die("no db"); if(!mysql_select_db("url_tester_db",$db)) die("No database selected."); $acc1="SELECT add_url from urls"; $acc2=mysql_query($acc1) or die("Could not select accounts."); ..............
View Replies !
View Related
Print From Array
how do you echo like this. i have an a array.. $stuff = array ( 'one' => Ƈ', 'two' => ƈ', 'three' => Ɖ'); and i'm doing this. echo $stuff['one']; and i get this. Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
View Replies !
View Related
Print An Array?
I just want to print an array. I did this here: $firstquarter = array(1 => 'January', 'February', 'March'); print_r($firstquarter); and print_r prints this: Array ( [1] => 'January' [2] => 'February' [3] => 'March' ) exactly what the PHP.net site said. But how do I just print out the all of it at once? print $firstquarter;
View Replies !
View Related
Print Array
why when I print array: echo "Test. $arr1[0]"; // Output is Test Array[0]. For scalar variable $a = "test2"; echo "$a2"; //Output test2. Why I cannot get variable from array?
View Replies !
View Related
Print Array?
I have this array... $array = array(); Array ( [12] => 0.820 [4] => 0.780 [2nd] => 0.480 [3rd] => 0.380 ) When I try to echo $array[2nd] or $array[3rd] I get the below error.Why? Parse error: parse error, unexpected T_STRING, expecting ']' in /homepages/xx/xxxxxxxxxx/htdocs/shipCalc.php on line 93
View Replies !
View Related
Array: Print
I print the last element of a one dimensional array. this is my code. PHP Code: $filename = split("/", $id); $id returns downloads/application/design/test.exe.
View Replies !
View Related
Adding New Values To An Array That Already Contains Values..
is it possible to append new values to an array that already has values in it?? say, i have my existing array; existing array; $array = array([66314] => 66314 , [66315] => 66315) ; then , when i check my checkbox on my next page, the ids should be appended to the $array: array that needs to be added to the $array; $array = array([66316] => 66316,[66317] => 66317,[66318] => 66318); how should it be done??
View Replies !
View Related
Selecting Array Rows Based On An Array Of Field=>values
Here's the code i have: $db = array(); //main array $db['main'] = array(); //table `main` $db['main'][] = array('id'=>0, 'username'=>'joshfrench','userpass'=>'password','userlevel'=>'admin'); //row $db['main'][] = array('id'=>1, 'username'=>'bob_smith','userpass'=>'psswrd','userlevel'=>'user'); //row function trim_value(&$value){ $value = strtolower(trim($value)); } function fdb_select($fields = "*", $table, $where = false, $limit = false){ global $db; $retv = $db[$table]; //LIMIT RESULTS TO FIELDS if(strrpos($fields, ",") === false){$field=array($fields);}else{$field = explode(",", $fields);}; array_walk($field, "trim_value"); $all_fields = array_keys($retv[0]); if($fields == '*'|| is_null($fields)){$field = $all_fields;}; $field = array_uintersect($all_fields, $field, "strcasecmp"); $retvi = array(); foreach($retv as $num =$row){ foreach($row as $fname =$fvalue){ $fname1 = strtolower($fname); if(in_array($fname1, $field)){ $retvi[$num][$fname]=$fvalue; }; }; }; //DONE LIMITING TO FIELDS if($where != false){ //UP TO HERE IT WORKS FINE //LIMIT TO WHERE CLAUSE $retvj = array(); foreach($retvi as $num =$row){ //IN THE ROW foreach($where as $k =$v){ //IF ROW MEETS ALL REQUIREMENTS if($row[$k] == $v){ $retvj[] = $retvi[$num]; //Keep that row }; }; }; //DONE LIMITING TO WHERE CLAUSE }; $retvi = (isset($retvj)) ? $retvj:$retvi; //SEND A FINAL ASSOCIATIVE ARRAY return $retvi; }; print_r(fdb_select("*", "main", array('id'=>"1", "username"=>"joshfrench"))); the previous code outputs this: Array ( [0] =Array ( [id] =0 [username] =joshfrench [userpass] =password [userlevel] =admin ) [1] =Array ( [id] =1 [username] =bob_smith [userpass] =psswrd [userlevel] =user ) )
View Replies !
View Related
Print Out A 2 Dimentional Array?
How do you print out a 2 dimentional array? One value or all values? while ($row = mysql_fetch_array($result)) { $abb = $row['abb']; $full = $row['full']; $vote = $row['vote']; $date = $row['accessdate']; $temparray[$accept] = array($abb, $full, $vote, $date);} echo $temparray?
View Replies !
View Related
Print Out Array Keys Only
Hi, there are lots of examples that show you how to print array values given a key. Do you know how to print keys for a given array. example $myArray = array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>4); How do you print 'a', 'b', 'c','d' only without using any loops?
View Replies !
View Related
Print The Array Contents?
I am new to PHP as such, and am trying to create an nusoap web service. I have created the following array on a server side script. On the client on receipt of $schedule, how can I go through and print the array contents? Code:
View Replies !
View Related
Accessing Array Values Inside A Multidimensional Array
I need to access a value which is inside in a multidimensional array... Suppose there is a form and where I takes all the form values inside an array named access..and I post the values into a different array. $registrationArray = $_POST['access']; Now I need to loop through this registration array and get values printed to the new variables... Suppose this is the array $access = array (fname,lname,date,year,month) How do I print the date,year,month values into different variable by looping through registration array..
View Replies !
View Related
Trying To Compare Array Values To A Value, Then Create Boolean Array
I have an array that returns data like this (see array below) The array[0] contains all the votes for one story as well as information that pertains to that vote, and the array[1] contains vote information for another story. What I need to do is check is a user_id stored in a session, is in the array, and then create a boolean array from that. For example, here I want to check if the user_id is featured in the first set of data, let's say my user_id is 74. Ok, so it is in the first set of data, so we set the boolean variable to true. Next I need to search the second data field for my user_id, 73. It is not featured here so the value in my array is set to 0. I need an array that returns values either 1, for true, your user_id was found in the table, or false, for your user_id was not featured in the table. They need to be in order of the story too. I'm having trouble one comparing the two variables against eachother, since the array is very deep, and two, creating the array on the fly. Code:
View Replies !
View Related
Print Opposite Array Setting.
lets say i have an array like so. $array = array('number 0'=>0,'number 1'=>1); is there a way without a while loop to reference and print the "number 0" portion?? such as referencing the "0" of the => portion?? i know that $array['number 0'] will print 0, but i need the exact opposite.
View Replies !
View Related
Print Order Of Assoctive Array
Ive got a series of 2 dimensional associative arrays while(list($key, $val) = each ($results)) { {foreach($val as $i=>$v) print "$i = $v"; } } but i want to define the order that the various $i's are printed in (not numerical/alphabetically) arrays named "key1_sorted_order" = keys in the order to be printed "key2_sorted_order" ive been experimeting with while(list($key, $val) = each ($results)) { {foreach($val as $i=>$v) $ks=$i.'_sorted_order' ($cntr=0;cntr<count($ks);$cntr++ ) { print [$ks[$cntr]] =$results[$val[$ks[$cntr]]] } } }
View Replies !
View Related
How To Print Elemnets Of N-dimensional Array?
What is a common way to print elements of a multidimensional array? I treid to do it in the straightforward way: $input_list[0][0] = "Something"; print "$input_list[0][0]"; And it does not work. The solution that I found is to use intermediate variable: $array = $input_list[0]; print "$array[0]"; printArray( $output_list[0] ); Are there any more elegant (or just common) ways to do it?
View Replies !
View Related
Print Image In Binary Array To Stdout
I'm still having the problem that I don't know how I can print the data of a jpeg image. I got the imagedata as return-value from a COM object. The imagedata are hold in a Variant SafeArray of bytes. Now I want to print the image header: header("Content-Type: image/jpeg") The php docs say, I should process these types in a foreach loop. So I try: foreach ($imgDataArray as $byte) { print decbin($byte); } When I try this on the commanline, I get: Content-Type: image/jpeg 11111111110110001111111111100000010000100101010001 101001001100011001100101001111...etc. This means: No binary image output. But the data signature is absolutely correct. I controlled it against the original jpg with a hex editor. I also tried some other ideas, but no succes.
View Replies !
View Related
Array Print Problem With Foreach Statment
I have an php script with, what I think is a small array problem....this is a piece of the code. Basically the loop gets data from a form then does an insert of the array into my database, which all woks except for the last field ....part_status... foreach($_POST["part"] as $key=>$val) { $qty = $_POST["qty"][$key]; $part_status = $_POST["part_status"][$key]; $data_insert.='("'.$val.'", "'.$qty.'", "'.$part_status.'"),'; echo "Part Number: $val QTY: $qty Part Status: $part_status<br /> "; } //remove last comma $data_insert=substr($data_insert,0,-1); $sql_parts="INSERT INTO tbl_service_calls_parts (part_number,qty, part_status) VALUES ".$data_insert.""; this is the result: ....What the hell is that "0" about.... it should say "Part Status" just like the line before it. Part Number: FF3-001-000 QTY: 2 Part Status: Part Used Part Number: AA2-001-000 QTY: 5 Part Status: 0 I'm at a loss, if I drop the "$part_status = $_POST["part_status"][$key];" the script works fine.
View Replies !
View Related
How To Print Variable Array From MySql Table Thru PHP
I have managed to writePHP code to draw my info line by line from the MySql database. My test script output the print in one long stream of info - but at least I know its doing what its supposed to as far as the retrieval is concerned. What I want to do now is print this info neatly. There are about 15 columns and up to 25 rows. Some of the columns MAY have info or may be blank. There may be one row or up to 25 rows, with a total row below that. Should I be creating a table (inside a layer) for the out put or printing one long line and then the next line in a loop...... I cant work out how to print a line at a time to fill a table that will vary in number of rows.
View Replies !
View Related
Simple Array
Running some queries and get an array returned that looks like this: Array ( => Array ( [max] => 4 ) ) Just wondering how to access '4'. Been trying simple echo commands (echo $maxID; echo $maxID[0]; echo $maxID[1]; echo $maxID['max']; but cant get anything. Obviously its something stupid im not realizing, just need a shove in the right direction.
View Replies !
View Related
Sort The Array By The Values In Array[$i][0]
How would I go about sorting the following array, I've been looking at array_multisort but to be honest I'm either not fully understanding it or it's not capable of what I'm trying to do. What I'd like to do is to sort the array by the values in array[$i][0] but I can't figure it out, the values being zzzz,a0,a1,00000000000000. PHP Code:
View Replies !
View Related
Simple Array Question
Hi there just wanted to ask something I currently have this snippet of code which is taken from log cleaner script I have running or working on getting working correctly. What I want to know is, down the bottom where it returns $data, how would I then extract that content to include in an email message??
View Replies !
View Related
Simple Algorithim With Array
i have got to produce a algorithm for an array. Firstly the array has ten numbers in it then i have to find the avg of the ten then after that i have to find the next largest number after the avg e.g if avg = 3.4 then other numbers are 6,8,5,10 then the answer would be 5.
View Replies !
View Related
How Much ~ Memory Does A Simple Array Eat?
say 500 items stored temporarily into an array variable with an id and title $temp_array[$ID] = $title; (title = varchar 150 character max) it's for a page where it may,.. or may not be called... but when it is called, it could be called 1 or 10 times (it's a search page...) so I'm wondering if it's more sensible to load into memory temporarily for a split second rather than do up to 10 mysql queries for the title.. again, assume an array with 500 items~ is it no point worrying about the 4k or, what even less? maybe 1k?
View Replies !
View Related
SecureURL Simple Array
What I am looking to have done is for someone to setup and array for an existing script. For you guys I am sure this would be quite easy, I have tried several different approaches myself and failed miserably each time. So perhaps I am missing the simple answer here. Basically this script takes the URL strings and encrypts them for when it gets passed. Problem is it is only doing this for links that are internal to the document. I'd like it to do it for all the links.
View Replies !
View Related
Simple Delete From Array?
Any way to do a simple delete from array? In other words, what would be the *easiest* (and fastest php runtime) way to delete "banana" from the following array: $my_array = array( "apple", "banana", "grape", "lime" ); .....so that $my_array will now be: $my_array = array( "apple", "grape", "lime" );
View Replies !
View Related
Simple Array Problem
I had this problem with arrays (can't remember what it was now) which went correct when using array(), but failed when using square-bracket syntax. It was something like this: $arr['first level']['second level'][1] = 'bla' $arr['first level']['second level'][2][ཇoneone'] = 'foo' $arr['first level']['second level'][2]['bar'] = false; Why doesn't that work. and does the following? $arr = array( 'first level' => array( 'second level' => array( 1 => 'bla', 2 => array( ཇoneone' => 'foo', 'bar' => false ) ) );
View Replies !
View Related
Simple Associative Array
Here's my problem: I have a list of ~2,000 email addresses from subscribers in a flat file on disk. Due to the newsletter being personalized per domain, I'd like to read the entire file into a structure like this: aol.com->[sherrij, foobar] mindspring.net->[tom111, t23s,13223] lycos.com->[dog,cat,tree] where the index (key?) of the array is the domain, and it points to another array of actual user names. my thought process is that i could use array_key_exists to search the array for an existing domain; if it exists, i'll then push it onto the array the domain points to.
View Replies !
View Related
Array To Simple Variables Assignment
Am I conflating PHP with another language (PERL maybe?) or can you do an assignment to $a, $b and $c something like ($a, $b, $c) = $array? The given sytax doesn't work nor does [$a, $b, $c] = $array. This leads me to believe in the conflation theory. If there is a syntax for this,
View Replies !
View Related
Bind Variables To A Simple Array
I'm very new to php. In my current code I'd like to bind variables to the values of a simply (only indexed by numbers [s. http://www.php-center.de/en-html-ma...pes.array.html]) array. Of course I noticed the function extract(), but this works on string indices. So I had the following idea: <?PHP function abind($array, $names) { // Return source binding the given $names to the elements // of the simple/linear array $array. $r = ""; for ($i = 0; $i < count($names); $i++) { $r = $r."$".current($names)." = $".$array."[".$i."];"; next($names); } return $r; } function test($arr) { // create bindings for $foo, $bar and $baz by evaluating "$foo = $arr[0]; ..." eval(abind("arr", array("foo", "bar", "baz"))); return $foo."-".$bar."-".$baz; } echo test(array(1, 2, 3)); ?> Of course function test will use $foo, $bar and $baz really oftern. I could as well use $arr[0] and so on, but I'd like to use more describing variable names. In this case the eval line would make things more succint and thus improve code readability. Am I missing something? Is this a standard/idiomatic way in php or is there some other?
View Replies !
View Related
Add Image Id's To A Simple 1 Dimensionsal Array.
I have started a session, and I add image id's to a simple 1 dimensionsal array. nothing complicated. as the sql executes in a do while loop, I add the image IDs to the array. PHP Code: //create array $search_result_array = array () ; //register session variable $_SESSION['search_result_array'] = $search_result_array ; PHP Code: echo count($search_result_array) ; .......
View Replies !
View Related
Simple Image Type Array Problem
Rather simple problem but I can't seem to get it solved. The second index of GetImageSize() just gives me integers which represent filetypes (i.e. 1 => GIF, 2 => JPG, etc.). What I want to do is create an array or somehow when I print $imagehw[2], the second index which displays the integers, I want it to display the filenames as opposed to the integer. Below I tried creating an array but all the output I get is, "array". BTW, $id is defined previously. I've tried php.net but I don't really understand their explanations and furthermore, nothing there really addresses my problems. The search here for previous posts on this subject resulted nothing significant. Code: <?php $imagehw = GetImageSize("images/$id"); $imagewidth = $imagehw[0]; $imageheight = $imagehw[1]; $imagetype = $imagehw[2]; $imagetype = array (".gif"=>"1", ".jpg"=>"2", ".jpeg"=>"2", ".png"=>"3", ".swf"=>"4", ".psd"=>"5", ".bmp"=>"6"); print "<b>Filename</b>: $id<br>"; print "<b>Image Filetype</b>: $imagetype<br>"; print "<b>Image Width</b>: $imagewidth<br>"; print "<b>Image Height</b>: $imageheight<br>"; ?>
View Replies !
View Related
|