Jump to content

php arrays


desithugg

Recommended Posts

array_search()

isnt the array function array_keys()?

 

Ted

yup but the fallowing worked for me

<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');

$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array);  // $key = 1;
?> 
soo i did
<?
$battle['move_1'] = "water";
$battle['move_2'] = "fire";
$battle['move_3'] = "thunder";
$battle['move_4'] = "rock";
$key = array_search('fire', $battle);  // $key = move_2;
?>

Link to comment
https://forums.phpfreaks.com/topic/44151-php-arrays/#findComment-214403
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.