SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: array values

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2007
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    array values

    Hi, is there a particular php function where i can retrieve a particular set of data from an array into another array like the example below without using "while" or any similar loop?

    PHP Code:
    array(2) {
      [
    0]=>
      array(
    3) {
        [
    "connID"]=>
        
    string(1"1"
        
    ["userID"]=>
        
    string(1"2"
        
    ["status"]=>
        
    string(1"0"
      
    }
      [
    1]=>
      array(
    3) {
        [
    "connID"]=>
        
    string(1"2"
        
    ["userID"]=>
        
    string(1"3"
        
    ["status"]=>
        
    string(1"0"
      
    }
    }

    Retrieve only "userID" and becomes:

    array(
    2) {2,3
    Thanks for any input.
    I Dunno LOL \(_o)/

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $newArray array_map( function ( $a ) { return $a['userID']; }, $oldArray ); 
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •