I want to convert this C# code to PHP code.
class Members
{
public int ID { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
}
class Process
{
Dictionary<string, Members> MemberList = new Dictionary<string, Members>();
public Process()
{
//GetMembersMethod();
//Fill MemberList
//example
//MemberList.Add(userid,new Members{id=@id,name=@name,surname=@surname});
}
void WriteMembers() {
foreach (string item in MemberList.Keys)
{
Console.WriteLine(MemberList[item].ID);
Console.WriteLine(MemberList[item].Name);
Console.WriteLine(MemberList[item].Surname);
}
}
}
How I can code this c# example in PHP? How can I code the loop to dictionary using array classes with PHP?
Edit..
I coded 2 days ago this code;
I want to like to this..
<?php
class CKN
{
public $Name= 'ozan';
public $Surname= 'ckn';
public $ID = '12';
}
$class = new CKN();
for($i=0; $i<10; $i++){
$class_temp= new CKN();
$class_temp->Name="ozan".$i;
$class_temp->Surname="CKN".$i;
$class_temp->ID="CKN".$i;
$arr[$i]=(object)$class_temp;
}
foreach($arr as $key => $value) {
$temp=new (CKN)$value;
foreach($temp as $k=>$v){
print "$k=> $v <br>";
}
}
?>
You could try using http://jsc.sourceforge.net/, which assists with .net to javascript, actionscript or php.
If you want to do it yourself:
I might have missed something, but that should get you started. Good luck.
EDIT: Here is code that I think does what you need. You can test it here: