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 7662445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:48:20+00:00 2026-05-31T13:48:20+00:00

The Key() function in php: The key() function simply returns the key of the

  • 0

The Key() function in php:

The key() function simply returns the key of the array element that’s currently being pointed to by the internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the end of the elements list or the array is empty, key() returns NULL.

Is their any thing simmilar to that in AS3.0?

Also on a side note: does .= in php mean the same as +=?

Here is an example of what I am trying to achieve. Based on the above info for the PHP Key() function converted to actionscript 3.

Essentially in PHP this is what Key() is used for:

<?php
$array = array(
    'fruit1' => 'apple',
    'fruit2' => 'orange',
    'fruit3' => 'grape',
    'fruit4' => 'apple',
    'fruit5' => 'apple');

// this cycle echoes all associative array
// key where value equals "apple"
while ($fruit_name = current($array)) {
    if ($fruit_name == 'apple') {
        echo key($array).'<br />';
    }
    next($array);
}
?>

The above example will output:

fruit1
fruit4
fruit5

You can see more at: https://www.php.net/manual/en/function.key.php

  • 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-05-31T13:48:22+00:00Added an answer on May 31, 2026 at 1:48 pm

    Your example uses a php array as an hash map or a dictionary. The documentation says:

    An array in PHP […] can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more.

    There is a dedicated class for that in as3 and it is called Dictionary. You can also use an Array, or any other dynamic object to achieve the same functionality. But let’s use Dictionary here. The documentation says:

    ActionScript 3.0 introduces an advanced type of associative array called a Dictionary …

    Also, the functions current() and next() are somehow implementations of the iterator pattern, which has no built in equivalent in as3. But the closest thing to the code you provided is, I think, the use of a simple for..in loop:

    for (var key:String in dictionary) {
        if (dictionary[key] == "apple")
            trace(key);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've noticed that PHP's current() and key() array functions ( like other array-pointer functions
in function need key to encrypt string without mcrypt libraly in php function encrypt($str,
I have a function that generates a key of 4 characters that has to
I have a perl function that takes an open registry key object. Now, I
I need to make a Function that receives a Session Key and a Session
I'm not terribly well versed with array manipulation in PHP, so I have a
Is it possible to use a regular expression with the php function array_key_exists() ?
I can bind a jquery event to this element like: <script type=text/javascript> $('#new_key').ready(function() {
I have a function which gets a key from the user and generates a
There is a function 'w32-toggle-lock-key to, effectively, simulate a press of capslock , numlock

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.