I Need help in this function

hey
i want a function do that,
select the action / name to be output : 2 => Weapon Mastery
[php]
( skill

( name  "Weapon Mastery")

( action 2)

( image	"passive001")

)
( skill

( name  "Lightning Slash")

( action 3)

( image	"active003")

)
[/php]
i tried that

[php]
function extract($string){

preg_match_all("/action [0-9]+/i", $string, $matches);
return $matches[0];

}

$outs = extract($text);

$ago = (implode($outs,",
"));

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

hey there, I think what you need to do is run the matches array through a foreach loop in order to output the results and use the button (i assume you’re using a button to select each “action”) to call the specific index in the array.
[php]
foreach($matches as $index => $value)
{
print “Action “.$index.” “.$value.”
”;
}
[/php]
that should output:
Action 2 Weapon Mastery
Action 3 Lightning Slash

now this just prints the values to the screen you would need some other mechanism in order to send only 1 to the screen at a time based on user input

Hope this helps

[php]function extractg($string){

preg_match_all("/action [a-zA-Z0-9\ “]+/i”, $string, $matches);
return $matches[0];

}

$outs = extractg($text);

foreach($outs as $index => $value)
{
print “Action “.$index.” “.$value.”
”;
}[/php]

outputs :
Action 0 action 2
Action 1 action 3

i ran this on my web server: (using wow abilities :slight_smile: )
[php]
$text = “action 1 deathstrike, action 2 scourgestrike”;
function extractg($string){

preg_match_all("/action [a-zA-Z0-9\ “]+/i”, $string, $matches);
return $matches[0];

}

$outs = extractg($text);

foreach($outs as $index => $value)
{
print $value."
";
}
[/php]
it outputs the following:
action 1 deathstrike
action 2 pummel

is this what you’re looking for?

yes thats because of the name / number of action in same value : 1 deathstrike
not like
(skill
( name “Weapon Mastery”)
( action 2)
)
(skill
( name “Lightning Slash”)
( action 3)
)
action > 2
name > Weapon Mastery

so if i selected action : output will be : 2 only
if i selected name : output will be : Weapon Mastery
i want the output will be the action and name both
2 => Weapon Mastery
is that possible ?

Sponsor our Newsletter | Privacy Policy | Terms of Service