Hi,
Trying to learn PHP. Need some help with arrays.
Trying to make an array with class objects that I can search.
<?php
class Name
{
var $FirstName, $SecondName;
function __construct($FirstName, $SecondName)
{
$this->FirstName = $FirstName;
$this->SecondName = $SecondName;
}
}
$TheNames=array(Name);
$TheNames[]=new Name("FirstName1","SecondName1");
$TheNames[]=new Name("FirstName2","SecondName2");
$TheNames[]=new Name("FirstName3","SecondName3");
$TheNames[]=new Name("FirstName4","SecondName4");
$TheNames[]=new Name("FirstName5","SecondName5");
$TheNames[]=new Name("FirstName6","SecondName6");
$TheNames[]=new Name("FirstName7","SecondName7");
print_r($TheNames); // So far so good !!!!
$key = array_search("FirstName5", ??????????? // But her I want to search for a specific object in the array, but I dont know how to....
echo "The key".$key
?>
Maby is it not possible to do this with array_search()!?
Any help apprecierad
/Mats
Trying to learn PHP. Need some help with arrays.
Trying to make an array with class objects that I can search.
<?php
class Name
{
var $FirstName, $SecondName;
function __construct($FirstName, $SecondName)
{
$this->FirstName = $FirstName;
$this->SecondName = $SecondName;
}
}
$TheNames=array(Name);
$TheNames[]=new Name("FirstName1","SecondName1");
$TheNames[]=new Name("FirstName2","SecondName2");
$TheNames[]=new Name("FirstName3","SecondName3");
$TheNames[]=new Name("FirstName4","SecondName4");
$TheNames[]=new Name("FirstName5","SecondName5");
$TheNames[]=new Name("FirstName6","SecondName6");
$TheNames[]=new Name("FirstName7","SecondName7");
print_r($TheNames); // So far so good !!!!
$key = array_search("FirstName5", ??????????? // But her I want to search for a specific object in the array, but I dont know how to....
echo "The key".$key
?>
Maby is it not possible to do this with array_search()!?
Any help apprecierad
/Mats