I Need help in this function

Discussion in 'PHP' started by DragoIF, Jan 9, 2012.

  1. #1
    hey
    i want a function do that,
    select the action / name to be output : 2 => Weapon Mastery

    ( skill
    
        ( name  "Weapon Mastery")
    
        ( action 2)
    
        ( image    "passive001")
    
    )
    ( skill
    
    
        ( name  "Lightning Slash")
    
        ( action 3)
    
        ( image    "active003")
    
    )
    PHP:
    i tried that
    function extract($string){
    
    preg_match_all("/action [0-9]+/i", $string, $matches);
      return $matches[0];
    
    }
    
    $outs = extract($text);
    
    
    $ago =  (implode($outs,",<br>"));
    
    print(preg_replace('/action/','',$ago));
    PHP:
    it successed and output is :
    2
    3
    but i didnt find the way to select the action / name in same time
    to be outputs : 2 => Weapon Mastery
     
    DragoIF, Jan 9, 2012 IP
  2. modz

    modz Well-Known Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    103
    #2
    Do you want to make an array(2 => 'Weapon Mastery', 3 => 'Lightning Slash'), so $array[2] to output 'Weapon Mastery', or you just want to output '2 => Weapon Mastery, 3 => Lightning Slash'?
     
    modz, Jan 9, 2012 IP
  3. DragoIF

    DragoIF Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    never mid i find good way to do what i want
    now i search on a function do that

    (item(name 4025)(desc 4001)(Index 4028)(Image "defs5v"))
    (item(name 4026)(desc 4002)(Index 4029)(Image "defs5j"))
    (item(name 4027)(desc 4003)(Index 4030)(Image "defs5s"))

    ( itemname 4025 "Shiun [Shield]")
    ( itemname 4026 "Adorned Shiun [Shield]")
    ( itemname 4027 "Ornate Shiun [Shield]")


    its possible to select item name and index for example
    Index 4028 => 4025 "Shiun [Shield]" ((name 4025 = itemname 4025))
    Index 4029 => 4026 "Adorned Shiun [Shield]" ((name 4026 = itemname 4025))

    Index 4030 => 4027 "Ornate Shiun [Shield]"

    is that possible
    i tried much time with preg_match_all function, but failed

     
    DragoIF, Jan 9, 2012 IP