Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8775005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:42:16+00:00 2026-06-13T18:42:16+00:00

$foo1 = array(bob, fred, jussi, jouni, egon, marliese); $bar1 = each($foo1); print ‘<pre>’; print_r($bar1);

  • 0
$foo1 = array("bob", "fred", "jussi", "jouni", "egon", "marliese");

$bar1 = each($foo1);
print '<pre>';
print_r($bar1);
print '</pre>';

The above code gives the following output:

Array
(
    [1] => bob
    [value] => bob
    [0] => 0
    [key] => 0
)

how to print other arrays that $bar1 contains? Like array for fred (in $foo1)?

* I know that it can be done using while, list and each
* I also know that foreach makes this task lot easier

I want to know if there is any handle that i can catch hold of and get something like the following output:

Array
(
    [1] => fred
    [value] => fred
    [0] => 0
    [key] => 0
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:42:17+00:00Added an answer on June 13, 2026 at 6:42 pm
    $foo1 = array("bob", "fred", "jussi", "jouni", "egon", "marliese");
    
    next($foo1);
    $bar1 = each($foo1);
    print '<pre>';
    print_r($bar1);
    print '</pre>';
    

    Generally, just move the array pointer to the desired location and call each.

    Outputs:

    Array
    (
        [1] => fred
        [value] => fred
        [0] => 0
        [key] => 0
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of arrays: arr = [[Foo1, Bar1, 1, W], [Foo2, Bar2,
I have an array of ActiveRecord objects, each one which has its own respective
These are my arrays: $foo1 = array (5) { [0] => 'foo1', [1] =>
My sorted array needs to be split up so that each created array has
I have an array, lets call it foo. Each element of the array holds
class A{ virtual int foo1(int a){ return foo1_1(a,filler(a)); } template<typename FunctionPtr_filler> int foo1_1(int a,
For example: void main(){ foo1(); } fooTarget(); foo1(foo2();); foo2(foo3();); foo3(foo4();); foo4(foo5();); foo5( foo6(); fooTarget();
I have a file that contains: foo1 = 1 foo2 = 2 foo3 =
> a = %w[foo1 foo2 foo3 foo4 foo5 foo6] => [foo1, foo2, foo3, foo4,
I have a file like this: foo, bar, foo1 bar, foo foo I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.