Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How can I print only part of the associative array?

Posted on 2011-05-09
5
Medium Priority
?
195 Views
Last Modified: 2012-08-13
how can i print only thr first x of items from an associative array?

Thank you
0
Comment
Question by:Nura111
  • 3
  • 2
5 Comments
 

Author Comment

by:Nura111
ID: 35723717
I figured I can use  pop()  but i dont want to effect the array
0
 
LVL 12

Accepted Solution

by:
enachemc earned 2000 total points
ID: 35723887
$i = 0;
for($arr as $k=>$v) {
$i += 1;
//print your values
if($i >= 10)break;
}
0
 

Author Comment

by:Nura111
ID: 35724157
not really working are you sure?
0
 
LVL 12

Expert Comment

by:enachemc
ID: 35726143
$i = 0;
for($arr as $k=>$v) {
$i += 1;
echo $v;
if($i >= 10)break;
}
0
 

Author Comment

by:Nura111
ID: 35730560
I guess you meant foreach, so I changed it and it work
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question