Jump to content

Recommended Posts

how do i echo all the elements with [0]?

<?php
   $file = fopen("getCalendar.csv", "r");
while(! feof($file))
  {
  print_r(fgetcsv($file));
  }

fclose($file);
?> 

 

the file generated is like this:

<------------------

Array ( [0] => id=5: ) Array ( [0] => id=8:'13/05/2009' [1] => '14/05/2009' [2] => '15/05/2009' [3] => '21/05/2009'

-------------->

Link to comment
https://forums.phpfreaks.com/topic/158028-echo-specific-elements-from-array/
Share on other sites

what am i doing wrong here?

i want to get all the keys[0] and their=> value

<?php
$file = fopen("getCalendar.asp", "r");
while(! feof($file))
{
$myArray[] = fgetcsv($file);
}

$tmp = array();
foreach($myArray as $key => $value){
$tmp[] = value;
}
print_r($tmp);
?>

 

what i get is

Array ( [0] => value [1] => value [2] => value [3] => value [4] etc

So...what's actually the problem?

 

And that foreach loop is unnecessary as you're essentially just repeating the while loop.

 

the problem is that i dont get the result :)

 

this the result i get when i call the file

Array ( [0] => id=5: ) Array ( [0] => id=8:'14/05/2009' [1] => '15/05/2009' [2] =>

etc

 

i want to get the values of all [0] =>

so the result will be

5

8

 

Idk what you're trying to do, but is this it?

<pre><?php
$file = fopen("index.php", "r");
while(!feof($file))
{
$myArray[] = fgetcsv($file);
}

print_r($myArray);
?>

 

ok with this i get the csv file as and array tree

now i want to get the values of elements with a [0\

 

here is part of the generated source

Array ( [0] => Array ( [0] => id=5: ) [1] => Array ( [0] => id=8:'14/05/2009' [1] => '15/05/2009' [2] =>

 

i want to get the value without the rest of the data so extract Array ( [0] => id=8:'14/05/2009' to

Array ( [0] => id=8:

and then echo a list

with the values

5

8

etc

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.