play_ Posted August 7, 2007 Share Posted August 7, 2007 Say i have an array like this: $example = array("first" => "hello", "second" => "world"); class Display { function __construct($example) { // here i'd do something so ii would end up with: // $this->first = "hello"; // $this->second = "world"; } } Been workin with extract() but can't get to it. ps: does anyone else keep pressing ctrl + s everytime you post a block of code here, because you're used to doing it all the time in your code editor? Link to comment https://forums.phpfreaks.com/topic/63671-solved-passing-array-as-argument-to-a-method/ Share on other sites More sharing options...
cooldude832 Posted August 7, 2007 Share Posted August 7, 2007 look into the expanded foreach that lets you grab keys/values Link to comment https://forums.phpfreaks.com/topic/63671-solved-passing-array-as-argument-to-a-method/#findComment-317315 Share on other sites More sharing options...
play_ Posted August 7, 2007 Author Share Posted August 7, 2007 Well what do you know. Didn't think it'd work but it did. Link to comment https://forums.phpfreaks.com/topic/63671-solved-passing-array-as-argument-to-a-method/#findComment-317323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.