473,320 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to split the index and the value in the array

65
Hello
My problem is when print out the array, it will include the index of the array and then value like this [0] => haha...
if i just want the value print out like "haha" only then what should i write?
Can some one guide me?Thank
May 16 '07 #1
2 1483
pbmods
5,821 Expert 4TB
print_r always outputs keys and values, since it is designed for debugging.

You can use a foreach loop to traverse through an array, though:

Expand|Select|Wrap|Line Numbers
  1. //  keys and values
  2. foreach($array as $key => $val)
  3.     print("[$key] => $val<br />");
  4.  
  5. //  values only
  6. foreach($array as $val)
  7.     print("$val<br />");
  8.  
  9. // keys only
  10. foreach(array_keys($array) as $key)
  11.     print("$key<br />");
  12.  
  13. //  or...
  14. foreach($array as $key => $val)
  15.     print("$key<br />");
  16.  
For more information:
http://php.net/foreach
May 16 '07 #2
wish
65
thanks a lot..i have done it
May 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Willem | last post by:
Hello I am quite hopeless and of course a newbe. The situation: Sql2k / query I would like it ot break down the following string: 2004 Inventory:Ex.Plant Farm1:1st Cut:Premium:0094
8
by: Geoff Cox | last post by:
Hello, If I have fred = "0 -10 5 6 "; how can I split above into groups of 2, ie 0,-10
3
by: Arjen | last post by:
Hi, How can I split a stringbuilder into arrays? Let's say I have a stringbuilder with this value "test1234567". Now I want an array with size 6. The value of the array have to be on index 0...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
7
by: lgbjr | last post by:
Hi All, I'm trying to split a string on every character. The string happens to be a representation of a hex number. So, my regex expression is (). Seems simple, but for some reason, I'm not...
2
by: Digital Fart | last post by:
following code would split a string "a != b" into 2 strings "a" and "b". but is there a way to know what seperator was used? string charSeparators = { "=", ">=", "<=" , "!=" }; string s1 =...
11
by: Brian | last post by:
I have been working on a data reception system.. I am still finding my way around Javascript, though I am accomplishing much. I just fixed a flaw that was really hard to find. The symptoms are...
5
kaleeswaran
by: kaleeswaran | last post by:
Hi! i stored the string value inside my array like "1,username" so i have to split the value user name and serial number. the array is: for(index=0; index < data.length;...
5
by: Steve | last post by:
I understand that string.split() should produce an array from a string. However when I use the following script the type of the result is indeed an object but the array elements are undefined. Why?...
1
by: Conrad Lender | last post by:
On 2008-10-14 03:06, dhtml wrote: .... .... .... JFTR, all of these would require an additional loop to find the index of the element with the value 3. "There's more than one way to do it"......
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.