Search Results

Search found 88 results on 4 pages for 'stdclass'.

Page 1/4 | 1 2 3 4  | Next Page >

  • How to access stdClass variables stdClass Object([max(id)])=>64)

    - by Theopile
    I need the very last valid entry in a database table which would be the row with the greatest primary key. So using mysqli, my query is "SELECT MAX(id) FROM table LIMIT 1". This query returns the correct number(using print_r()) but I cannot figure out how to access it. Here is the main code. Note that the $this-link refers to class with a mysqli connection. $q="select max(id) from stones limit 1"; $qed=$this->link->query($q) or die(mysqli_error()); if($qed){ $row=$qed->fetch_object(); print_r($row); echo $lastid=$row;//here is the problem } The valid line print_r($row) echos out "stdClass Object ( [max(id)] = 68 )"

    Read the article

  • Add properties to stdClass object from another object

    - by Florin
    I would like to be able to do the following: $obj = new stdClass; $obj->status = "success"; $obj2 = new stdClass; $obj2->message = "OK"; How can I extend $obj so that it contains the properties of $obj2, eg: $obj->status //"success" $obj->message // "OK" I know I could use an array, add all properties to the array and then cast that back to object, but is there a more elegant way, something like this: extend($obj, $obj2); //adds all properties from $obj2 to $obj Thanks!

    Read the article

  • php split array into smaller even arrays

    - by SoulieBaby
    I have a function that is supposed to split my array into smaller, evenly distributed arrays, however it seems to be duplicating my data along the way. If anyone can help me out that'd be great. Here's the original array: Array ( [0] => stdClass Object ( [bid] => 42 [name] => Ray White Mordialloc [imageurl] => sp_raywhite.gif [clickurl] => http://www.raywhite.com/ ) [1] => stdClass Object ( [bid] => 48 [name] => Beachside Osteo [imageurl] => sp_beachside.gif [clickurl] => http://www.beachsideosteo.com.au/ ) [2] => stdClass Object ( [bid] => 53 [name] => Carmotive [imageurl] => sp_carmotive.jpg [clickurl] => http://www.carmotive.com.au/ ) [3] => stdClass Object ( [bid] => 51 [name] => Richmond and Bennison [imageurl] => sp_richmond.jpg [clickurl] => http://www.richbenn.com.au/ ) [4] => stdClass Object ( [bid] => 50 [name] => Letec [imageurl] => sp_letec.jpg [clickurl] => www.letec.biz ) [5] => stdClass Object ( [bid] => 39 [name] => Main Street Mordialloc [imageurl] => main street cafe.jpg [clickurl] => ) [6] => stdClass Object ( [bid] => 40 [name] => Ripponlea Mitsubishi [imageurl] => sp_mitsubishi.gif [clickurl] => ) [7] => stdClass Object ( [bid] => 34 [name] => Adrianos Pizza & Pasta [imageurl] => sp_adrian.gif [clickurl] => ) [8] => stdClass Object ( [bid] => 59 [name] => Pure Sport [imageurl] => sp_psport.jpg [clickurl] => http://www.puresport.com.au/ ) [9] => stdClass Object ( [bid] => 33 [name] => Two Brothers [imageurl] => sp_2brothers.gif [clickurl] => http://www.2brothers.com.au/ ) [10] => stdClass Object ( [bid] => 52 [name] => Mordialloc Travel and Cruise [imageurl] => sp_morditravel.jpg [clickurl] => http://www.yellowpages.com.au/vic/mordialloc/mordialloc-travel-cruise-13492525-listing.html ) [11] => stdClass Object ( [bid] => 57 [name] => Southern Suburbs Physiotherapy Centre [imageurl] => sp_sspc.jpg [clickurl] => http://www.sspc.com.au ) [12] => stdClass Object ( [bid] => 54 [name] => PPM Builders [imageurl] => sp_ppm.jpg [clickurl] => http://www.hotfrog.com.au/Companies/P-P-M-Builders ) [13] => stdClass Object ( [bid] => 36 [name] => Big River [imageurl] => sp_bigriver.gif [clickurl] => ) [14] => stdClass Object ( [bid] => 35 [name] => Bendigo Bank Parkdale / Mentone East [imageurl] => sp_bendigo.gif [clickurl] => http://www.bendigobank.com.au ) [15] => stdClass Object ( [bid] => 56 [name] => Logical Services [imageurl] => sp_logical.jpg [clickurl] => ) [16] => stdClass Object ( [bid] => 58 [name] => Dicount Lollie Shop [imageurl] => new dls logo.jpg [clickurl] => ) [17] => stdClass Object ( [bid] => 46 [name] => Patterson Securities [imageurl] => cmyk patersons_withtag.jpg [clickurl] => ) [18] => stdClass Object ( [bid] => 44 [name] => Mordialloc Personal Trainers [imageurl] => sp_mordipt.gif [clickurl] => # ) [19] => stdClass Object ( [bid] => 37 [name] => Mordialloc Cellar Door [imageurl] => sp_cellardoor.gif [clickurl] => ) [20] => stdClass Object ( [bid] => 41 [name] => Print House Graphics [imageurl] => sp_printhouse.gif [clickurl] => ) [21] => stdClass Object ( [bid] => 55 [name] => 360South [imageurl] => sp_360.jpg [clickurl] => ) [22] => stdClass Object ( [bid] => 43 [name] => Systema [imageurl] => sp_systema.gif [clickurl] => ) [23] => stdClass Object ( [bid] => 38 [name] => Lowe Financial Group [imageurl] => sp_lowe.gif [clickurl] => http://lowefinancial.com/ ) [24] => stdClass Object ( [bid] => 49 [name] => Kim Reed Conveyancing [imageurl] => sp_kimreed.jpg [clickurl] => ) [25] => stdClass Object ( [bid] => 45 [name] => Mordialloc Sporting Club [imageurl] => msc logo.jpg [clickurl] => ) ) Here's the php function which is meant to split the array: function split_array($array, $slices) { $perGroup = floor(count($array) / $slices); $Remainder = count($array) % $slices ; $slicesArray = array(); $i = 0; while( $i < $slices ) { $slicesArray[$i] = array_slice($array, $i * $perGroup, $perGroup); $i++; } if ( $i == $slices ) { if ($Remainder > 0 && $Remainder < $slices) { $z = $i * $perGroup +1; $x = 0; while ($x < $Remainder) { $slicesRemainderArray = array_slice($array, $z, $Remainder+$x); $remainderItems = array_merge($slicesArray[$x],$slicesRemainderArray); $slicesArray[$x] = $remainderItems; $x++; $z++; } } }; return $slicesArray; } Here's the result of the split (it somehow duplicates items from the original array into the smaller arrays): Array ( [0] => Array ( [0] => stdClass Object ( [bid] => 57 [name] => Southern Suburbs Physiotherapy Centre [imageurl] => sp_sspc.jpg [clickurl] => http://www.sspc.com.au ) [1] => stdClass Object ( [bid] => 35 [name] => Bendigo Bank Parkdale / Mentone East [imageurl] => sp_bendigo.gif [clickurl] => http://www.bendigobank.com.au ) [2] => stdClass Object ( [bid] => 38 [name] => Lowe Financial Group [imageurl] => sp_lowe.gif [clickurl] => http://lowefinancial.com/ ) [3] => stdClass Object ( [bid] => 39 [name] => Main Street Mordialloc [imageurl] => main street cafe.jpg [clickurl] => ) [4] => stdClass Object ( [bid] => 48 [name] => Beachside Osteo [imageurl] => sp_beachside.gif [clickurl] => http://www.beachsideosteo.com.au/ ) [5] => stdClass Object ( [bid] => 33 [name] => Two Brothers [imageurl] => sp_2brothers.gif [clickurl] => http://www.2brothers.com.au/ ) [6] => stdClass Object ( [bid] => 40 [name] => Ripponlea Mitsubishi [imageurl] => sp_mitsubishi.gif [clickurl] => ) ) [1] => Array ( [0] => stdClass Object ( [bid] => 44 [name] => Mordialloc Personal Trainers [imageurl] => sp_mordipt.gif [clickurl] => # ) [1] => stdClass Object ( [bid] => 41 [name] => Print House Graphics [imageurl] => sp_printhouse.gif [clickurl] => ) [2] => stdClass Object ( [bid] => 39 [name] => Main Street Mordialloc [imageurl] => main street cafe.jpg [clickurl] => ) [3] => stdClass Object ( [bid] => 48 [name] => Beachside Osteo [imageurl] => sp_beachside.gif [clickurl] => http://www.beachsideosteo.com.au/ ) [4] => stdClass Object ( [bid] => 33 [name] => Two Brothers [imageurl] => sp_2brothers.gif [clickurl] => http://www.2brothers.com.au/ ) [5] => stdClass Object ( [bid] => 40 [name] => Ripponlea Mitsubishi [imageurl] => sp_mitsubishi.gif [clickurl] => ) ) [2] => Array ( [0] => stdClass Object ( [bid] => 56 [name] => Logical Services [imageurl] => sp_logical.jpg [clickurl] => ) [1] => stdClass Object ( [bid] => 43 [name] => Systema [imageurl] => sp_systema.gif [clickurl] => ) [2] => stdClass Object ( [bid] => 48 [name] => Beachside Osteo [imageurl] => sp_beachside.gif [clickurl] => http://www.beachsideosteo.com.au/ ) [3] => stdClass Object ( [bid] => 33 [name] => Two Brothers [imageurl] => sp_2brothers.gif [clickurl] => http://www.2brothers.com.au/ ) [4] => stdClass Object ( [bid] => 40 [name] => Ripponlea Mitsubishi [imageurl] => sp_mitsubishi.gif [clickurl] => ) ) [3] => Array ( [0] => stdClass Object ( [bid] => 53 [name] => Carmotive [imageurl] => sp_carmotive.jpg [clickurl] => http://www.carmotive.com.au/ ) [1] => stdClass Object ( [bid] => 45 [name] => Mordialloc Sporting Club [imageurl] => msc logo.jpg [clickurl] => ) [2] => stdClass Object ( [bid] => 33 [name] => Two Brothers [imageurl] => sp_2brothers.gif [clickurl] => http://www.2brothers.com.au/ ) [3] => stdClass Object ( [bid] => 40 [name] => Ripponlea Mitsubishi [imageurl] => sp_mitsubishi.gif [clickurl] => ) ) [4] => Array ( [0] => stdClass Object ( [bid] => 59 [name] => Pure Sport [imageurl] => sp_psport.jpg [clickurl] => http://www.puresport.com.au/ ) [1] => stdClass Object ( [bid] => 54 [name] => PPM Builders [imageurl] => sp_ppm.jpg [clickurl] => http://www.hotfrog.com.au/Companies/P-P-M-Builders ) [2] => stdClass Object ( [bid] => 40 [name] => Ripponlea Mitsubishi [imageurl] => sp_mitsubishi.gif [clickurl] => ) ) [5] => Array ( [0] => stdClass Object ( [bid] => 46 [name] => Patterson Securities [imageurl] => cmyk patersons_withtag.jpg [clickurl] => ) [1] => stdClass Object ( [bid] => 34 [name] => Adriano's Pizza & Pasta [imageurl] => sp_adrian.gif [clickurl] => # ) ) [6] => Array ( [0] => stdClass Object ( [bid] => 55 [name] => 360South [imageurl] => sp_360.jpg [clickurl] => ) [1] => stdClass Object ( [bid] => 37 [name] => Mordialloc Cellar Door [imageurl] => sp_cellardoor.gif [clickurl] => ) ) [7] => Array ( [0] => stdClass Object ( [bid] => 49 [name] => Kim Reed Conveyancing [imageurl] => sp_kimreed.jpg [clickurl] => ) [1] => stdClass Object ( [bid] => 58 [name] => Dicount Lollie Shop [imageurl] => new dls logo.jpg [clickurl] => ) ) [8] => Array ( [0] => stdClass Object ( [bid] => 51 [name] => Richmond and Bennison [imageurl] => sp_richmond.jpg [clickurl] => http://www.richbenn.com.au/ ) [1] => stdClass Object ( [bid] => 52 [name] => Mordialloc Travel and Cruise [imageurl] => sp_morditravel.jpg [clickurl] => http://www.yellowpages.com.au/vic/mordialloc/mordialloc-travel-cruise-13492525-listing.html ) ) [9] => Array ( [0] => stdClass Object ( [bid] => 50 [name] => Letec [imageurl] => sp_letec.jpg [clickurl] => www.letec.biz ) [1] => stdClass Object ( [bid] => 36 [name] => Big River [imageurl] => sp_bigriver.gif [clickurl] => ) ) ) ^^ As you can see there are duplicates from the original array in the newly created smaller arrays. I thought I could remove the duplicates using a multi-dimensional remove duplicate function but that didn't work. I'm guessing my problem is in the array_split function. Any suggestions? :)

    Read the article

  • php remove duplicates from array..

    - by SoulieBaby
    Hi all, I was wondering if anyone could help me out, I'm trying to find a script that will check my entire array and remove any duplicates if required, then spit out the array in the same format. Here's an example of my array (as you will see there are some duplicates): Array ( [0] => Array ( [0] => stdClass Object ( [bid] => 34 [name] => Adrianos Pizza & Pasta [imageurl] => sp_adrian.gif [clickurl] => # ) [1] => stdClass Object ( [bid] => 42 [name] => Ray White Mordialloc [imageurl] => sp_raywhite.gif [clickurl] => http://www.raywhite.com/ ) [2] => stdClass Object ( [bid] => 48 [name] => Beachside Osteo [imageurl] => sp_beachside.gif [clickurl] => http://www.beachsideosteo.com.au/ ) [3] => stdClass Object ( [bid] => 57 [name] => Southern Suburbs Physiotherapy Centre [imageurl] => sp_sspc.jpg [clickurl] => http://www.sspc.com.au ) [4] => stdClass Object ( [bid] => 52 [name] => Mordialloc Travel and Cruise [imageurl] => sp_morditravel.jpg [clickurl] => http://www.yellowpages.com.au/vic/mordialloc/mordialloc-travel-cruise-13492525-listing.html ) [5] => stdClass Object ( [bid] => 37 [name] => Mordialloc Cellar Door [imageurl] => sp_cellardoor.gif [clickurl] => ) [6] => stdClass Object ( [bid] => 53 [name] => Carmotive [imageurl] => sp_carmotive.jpg [clickurl] => http://www.carmotive.com.au/ ) ) [1] => Array ( [0] => stdClass Object ( [bid] => 55 [name] => 360South [imageurl] => sp_360.jpg [clickurl] => ) [1] => stdClass Object ( [bid] => 40 [name] => Ripponlea Mitsubishi [imageurl] => sp_mitsubishi.gif [clickurl] => ) [2] => stdClass Object ( [bid] => 57 [name] => Southern Suburbs Physiotherapy Centre [imageurl] => sp_sspc.jpg [clickurl] => http://www.sspc.com.au ) [3] => stdClass Object ( [bid] => 52 [name] => Mordialloc Travel and Cruise [imageurl] => sp_morditravel.jpg [clickurl] => http://www.yellowpages.com.au/vic/mordialloc/mordialloc-travel-cruise-13492525-listing.html ) [4] => stdClass Object ( [bid] => 37 [name] => Mordialloc Cellar Door [imageurl] => sp_cellardoor.gif [clickurl] => ) [5] => stdClass Object ( [bid] => 53 [name] => Carmotive [imageurl] => sp_carmotive.jpg [clickurl] => http://www.carmotive.com.au/ ) ) [2] => Array ( [0] => stdClass Object ( [bid] => 44 [name] => Mordialloc Personal Trainers [imageurl] => sp_mordipt.gif [clickurl] => # ) [1] => stdClass Object ( [bid] => 36 [name] => Big River [imageurl] => sp_bigriver.gif [clickurl] => ) [2] => stdClass Object ( [bid] => 52 [name] => Mordialloc Travel and Cruise [imageurl] => sp_morditravel.jpg [clickurl] => http://www.yellowpages.com.au/vic/mordialloc/mordialloc-travel-cruise-13492525-listing.html ) [3] => stdClass Object ( [bid] => 37 [name] => Mordialloc Cellar Door [imageurl] => sp_cellardoor.gif [clickurl] => ) [4] => stdClass Object ( [bid] => 53 [name] => Carmotive [imageurl] => sp_carmotive.jpg [clickurl] => http://www.carmotive.com.au/ ) ) [3] => Array ( [0] => stdClass Object ( [bid] => 41 [name] => Print House Graphics [imageurl] => sp_printhouse.gif [clickurl] => ) [1] => stdClass Object ( [bid] => 49 [name] => Kim Reed Conveyancing [imageurl] => sp_kimreed.jpg [clickurl] => ) [2] => stdClass Object ( [bid] => 37 [name] => Mordialloc Cellar Door [imageurl] => sp_cellardoor.gif [clickurl] => ) [3] => stdClass Object ( [bid] => 53 [name] => Carmotive [imageurl] => sp_carmotive.jpg [clickurl] => http://www.carmotive.com.au/ ) ) [4] => Array ( [0] => stdClass Object ( [bid] => 38 [name] => Lowe Financial Group [imageurl] => sp_lowe.gif [clickurl] => http://lowefinancial.com/ ) [1] => stdClass Object ( [bid] => 58 [name] => Dicount Lollie Shop [imageurl] => new dls logo.jpg [clickurl] => ) [2] => stdClass Object ( [bid] => 53 [name] => Carmotive [imageurl] => sp_carmotive.jpg [clickurl] => http://www.carmotive.com.au/ ) ) [5] => Array ( [0] => stdClass Object ( [bid] => 45 [name] => Mordialloc Sporting Club [imageurl] => msc logo.jpg [clickurl] => ) [1] => stdClass Object ( [bid] => 33 [name] => Two Brothers [imageurl] => sp_2brothers.gif [clickurl] => http://www.2brothers.com.au/ ) ) [6] => Array ( [0] => stdClass Object ( [bid] => 46 [name] => Patterson Securities [imageurl] => cmyk patersons_withtag.jpg [clickurl] => ) [1] => stdClass Object ( [bid] => 56 [name] => Logical Services [imageurl] => sp_logical.jpg [clickurl] => ) ) [7] => Array ( [0] => stdClass Object ( [bid] => 59 [name] => Pure Sport [imageurl] => sp_psport.jpg [clickurl] => http://www.puresport.com.au/ ) [1] => stdClass Object ( [bid] => 51 [name] => Richmond and Bennison [imageurl] => sp_richmond.jpg [clickurl] => http://www.richbenn.com.au/ ) ) [8] => Array ( [0] => stdClass Object ( [bid] => 39 [name] => Main Street Mordialloc [imageurl] => main street cafe.jpg [clickurl] => ) [1] => stdClass Object ( [bid] => 50 [name] => Letec [imageurl] => sp_letec.jpg [clickurl] => www.letec.biz ) ) [9] => Array ( [0] => stdClass Object ( [bid] => 54 [name] => PPM Builders [imageurl] => sp_ppm.jpg [clickurl] => http://www.hotfrog.com.au/Companies/P-P-M-Builders ) [1] => stdClass Object ( [bid] => 43 [name] => Systema [imageurl] => sp_systema.gif [clickurl] => ) ) )

    Read the article

  • PHP - warning - Undefined property: stdClass - fix?

    - by Phill Pafford
    I get this warning in my error logs and wanted to know how to correct this issues in my code. Warning: PHP Notice: Undefined property: stdClass::$records in script.php on line 440 Some Code: // Parse object to get account id's // The response doesn't have the records attribute sometimes. $role_arr = getRole($response->records); // Line 440 Response if records exists stdClass Object ( [done] => 1 [queryLocator] => [records] => Array ( [0] => stdClass Object ( [type] => User [Id] => [any] => stdClass Object ( [type] => My Role [Id] => [any] => <sf:Name>My Name</sf:Name> ) ) ) [size] => 1 ) Response if records does not exist stdClass Object ( [done] => 1 [queryLocator] => [size] => 0 ) I was thinking something like array_key_exists() functionality but for objects, anything? or am I going about this the wrong way?

    Read the article

  • PHP array of object(stdClass) fusion/intersect?

    - by Gremo
    $arr1 is an associative array of anonymus objects: array 15898 => object(stdClass)[8] public 'date' => int $arr2 is another associative array with two (or more, it's not fixed) properties: array 15898 => object(stdClass)[10] public 'fruits' public 'drinks' I can't find any function for intersect and content fusion when dealing with objects. Basically i'd like to obtain: array 15898 => object(stdClass)[8] public 'date' => int public 'fruits' public 'drinks' Question is: is this even possible?

    Read the article

  • Twitter Trends API weekly.json causing error "Cannot use object of type stdClass as array"

    - by tucson
    I have the following PHP code: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); curl_close($ch); $obj = json_decode($result); foreach ($obj[0]->trends as $trend) echo utf8_decode($trend->name); which works fine for URL #1 (into the variable $URL): http://api.twitter.com/1/trends/1.json?exclude=hashtags but causes an error "Cannot use object of type stdClass as array" for URL #2: http://api.twitter.com/1/trends/weekly.json?exclude=hashtags I have searched for a while, but can't figure out a code to fix this and handle both URLs. Any help would be much appreciated.

    Read the article

  • PHP, is_array() generating an "Undefined property: stdClass::$crit " error

    - by Brook Julias
    is_array($src2->crit) is generating an "Undefined property: stdClass::$crit" error. The line throwing the error is: if(is_array($src2->crit) && count($src->crit) > 0){ $src2->crit is initialized here. $src2->crit = array(); $src2->crit[0] = new dataSet(); $src2->crit[0]->tblName = $tbl2; $src2->crit[0]->colName = "ID"; $src2->crit[0]->val = $elm->editID; When testing $src2->crit with this code. print("\$src->crit is a ".$src->crit."<br />"); print_r($src->crit); print("<br />"); This is returned. $src2->crit is a Array Array ( [0] => dataSet Object ( [tblName] => sExam [colName] => ID [val] => 10 ) ) What am I not seeing/understanding correctly? If print("\$src2->crit is a ".$src->crit."<br />") returns that it is an array then why is is_array($src2->$crit) generating an error?

    Read the article

  • PHP Notice: Undefined property: stdClass:

    - by 4D
    I've got an array coming back from a Flash app created in Flash Builder 4. I have a service setup that queries and brings data back from the DB successfully, however the Update script is generating the Undefined Property errors. I'm still learning both PHP and Flash Builder, and don't fully understand what the $this- commands do. If anyone can suggest where this script is going wrong, it is basically just generated by Flash Builder and is not something I've developed myself, I would appreciate it? Also if someone can explain $this- to me that would be awesome too? I've seen them before, but then I've seen scripts doing the same thing that do not use them, so is this an old way of doing things? Really appreciate any input anyone can give. public function updateItem($item) { // TODO Auto-generated method stub // Update an existing record in the database and return the item // Sample code \' $this->connect(); $sql = "UPDATE tbltrust SET inst_code = '$item->inst_code', trust_name = '$item->trust_name', trust_code = '$item->trust_code' WHERE trust_key = '$item->trust_key'"; mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection)); mysqli_close($this->connection); }

    Read the article

  • foreach with an array of stdclass objects

    - by Jared Steffen
    So, what I want to do is quite simple in my mind. I have an array that consists solely of four objects. I want to create a loop that will echo an attribute of each object in the array. The only success I've had, however, is echoing every object and every property of the objects. I've never dealt with objects so this is probably the TRUE root of the problem. There's been a few revisions but the only thing I've really excelled at is creating error codes. Here is what I have: $categories = get_categories(array('child_of' => '8')); foreach ($categories as $cat) { echo $cat->name; };

    Read the article

  • Get Instance ID of an Object in PHP

    - by Alix Axel
    I've learn a while ago on StackOverflow that we can get the "instance ID" of any resource, for instance: var_dump(intval(curl_init())); // int(2) var_dump(intval(finfo_open())); // int(3) var_dump(intval(curl_init())); // int(4) var_dump(intval(finfo_open())); // int(5) var_dump(intval(curl_init())); // int(6) I need something similar but applied to classes: var_dump(intval(new stdClass())); // int(1) var_dump(intval(new stdClass())); // int(1) var_dump(intval(new stdClass())); // int(1) var_dump(intval(new stdClass())); // int(1) var_dump(intval(new stdClass())); // int(1) I'm using stdClass just has an example here, but as you can see, it's not the output I was hoping for. I just did some more testing and I found that var_dump() can see the instance ID of an object: var_dump($a = new stdClass()); // object(stdClass)#1 (0) { } var_dump($b = new stdClass()); // object(stdClass)#2 (0) { } var_dump($c = new stdClass()); // object(stdClass)#3 (0) { } The same happens with resources of course: var_dump(curl_init()); // resource(2) of type (curl) var_dump(curl_init()); // resource(3) of type (curl) var_dump(curl_init()); // resource(4) of type (curl) Is there any way to achieve the same effect in PHP?

    Read the article

  • convert std object class to comma seperated string

    - by Kwaasi Djin
    I have an std class object from twitter and i would like to take the ids array values and put them in a php variable $ids where $ids = (15761916,30144785,382747195,19399719). I imagine using a for loop and using phps implode but i'm not sure how to go about it. stdClass Object ( [ids] => Array ( [0] => 15761916 [1] => 30144785 [2] => 382747195 [3] => 19399719 ) [next_cursor] => 0 [next_cursor_str] => 0 [previous_cursor] => 0 [previous_cursor_str] => 0 )

    Read the article

  • transforming flat php array into multidimensional one based on key value?

    - by PopRocks4344
    I have a flat array that I'm trying to make multidimensional. Basically, I want to find the items that have parents and create a subarray for that parent id. Right now (and this is simplified), it looks like this: Array ( [0] => stdClass Object ( [id] => 1 [parent] => 0 [name ] => Parent1 ) [1] => stdClass Object ( [id] => 7 [parent] => 1 [name] => Child1 ) [2] => stdClass Object ( [id] => 9 [parent] => 1 [name] => Child2 ) [3] => stdClass Object ( [id] => 2 [parent] => 0 [name ] => Parent2 ) [4] => stdClass Object ( [id] => 88 [parent] => 2 [name] => Childof2 ) ) I'm trying to make this: Array ( [0] => stdClass Object ( [id] => 1 [parent] => 0 [name ] => Parent1 [children] => stdClass Object ( [1] => stdClass Object ( [id] => 7 [parent] => 1 [name] => Child1 ) [2] => stdClass Object ( [id] => 9 [parent] => 1 [name] => Child2 ) ) ) [1] => stdClass Object ( [id] => 2 [parent] => 0 [name ] => Parent2 [children] => stdClass Object ( [0] => stdClass Object ( [id] => 88 [parent] => 2 [name] => Childof2 ) ) ) )

    Read the article

  • Grouping php array items based on user and created time

    - by Jim
    This is an array of objects showing a user uploading photos: Array ( [12] => stdClass Object ( [type] => photo [created] => 2010-05-14 23:36:41 [user] => stdClass Object ( [id] => 760 [username] => mrsmith ) [photo] => stdClass Object ( [id] => 4181 ) ) [44] => stdClass Object ( [type] => photo [created] => 2010-05-14 23:37:15 [user] => stdClass Object ( [id] => 760 [username] => mrsmith ) [photo] => stdClass Object ( [id] => 4180 ) ) ) However instead of showing: mr smith uploaded one photo mr smith uploaded one photo I'd like to display: mr smith uploaded two photos by grouping similar items, grouping by user ID and them having added them within, let's say 15 minutes of each other. So I'd like to get the array in this sort of shape: Array ( [12] => stdClass Object ( [type] => photo [created] => 2010-05-14 23:36:41 [user] => stdClass Object ( [id] => 760 [username] => mrsmith ) [photos] => Array ( [0] => stdClass Object ( [id] => 4181 ) [1] => stdClass Object ( [id] => 4180 ) ) ) ) preserving the first item of the group and it's created time, and supplementing it with any other groupable photos and then unsetting any items that were grouped (so the final array doesn't have key 44 anymore as it was grouped in with 12). The array contains other actions than just photos, hence the original keys of 12 and 44. I just can't figure out a way to do this efficiently. I used to use MySQL and PHP to do this but am trying to just use pure PHP for caching reasons. Can anyone shed any insights? I thought about going through each item and seeing if I can group it with the previous one in the array but the previous one might not necessarily be relevant or even a photo. I've got total brain freeze :(

    Read the article

  • How would i access the properties in this object? Twitter API

    - by Tapha
    I have stores this object in an variable called results. How would i access the profile_image_url for example. Here is the return value with print_r: stdClass Object ( [results] => Array ( [0] => stdClass Object ( [profile_image_url] => http://a3.twimg.com/profile_images/685278639/twitter-logo_normal.jpg [created_at] => Mon, 10 May 2010 11:29:44 +0000 [from_user] => BarclaysWealth [metadata] => stdClass Object ( [result_type] => recent ) [to_user_id] => [text] => RT @BarclaysStock: Investment ViewPoint - We take a look at what a hung parliament could mean for the UK economy http://bit.ly/OaYh7 [id] => 13721505359 [from_user_id] => 14895786 [geo] => [iso_language_code] => en [source] => <a href="http://twitter.com/">web</a> ) [1] => stdClass Object ( [profile_image_url] => http://a1.twimg.com/profile_images/671523082/32fb0a8_normal.jpg [created_at] => Fri, 07 May 2010 21:02:10 +0000 [from_user] => InfoFocus [metadata] => stdClass Object ( [result_type] => recent ) [to_user_id] => [text] => RT @BarclaysWealth: RT @BarclaysStock: Investment ViewPoint - We take a look at what a hung parliament could mean for the UK economy http://bit.ly/OaYh7 [id] => 13569384857 [from_user_id] => 85742792 [geo] => [iso_language_code] => en [source] => <a href="http://www.hootsuite.com" rel="nofollow">HootSuite</a> ) [2] => stdClass Object ( [profile_image_url] => http://a3.twimg.com/profile_images/685278639/twitter-logo_normal.jpg [created_at] => Fri, 07 May 2010 20:59:20 +0000 [from_user] => BarclaysWealth [metadata] => stdClass Object ( [result_type] => recent ) [to_user_id] => [text] => RT @BarclaysStock: Investment ViewPoint - We take a look at what a hung parliament could mean for the UK economy http://bit.ly/OaYh7 [id] => 13569257933 [from_user_id] => 14895786 [geo] => [iso_language_code] => en [source] => <a href="http://www.hootsuite.com" rel="nofollow">HootSuite</a> ) [3] => stdClass Object ( [profile_image_url] => http://a1.twimg.com/profile_images/485934856/BD_Icon_Twitter_small_normal.gif [created_at] => Fri, 07 May 2010 16:35:56 +0000 [from_user] => BARXdirect [metadata] => stdClass Object ( [result_type] => recent ) [to_user_id] => [text] => RT @BarclaysStock: Investment ViewPoint - We take a look at what a hung parliament could mean for the UK economy http://bit.ly/OaYh7 [id] => 13557670463 [from_user_id] => 66715243 [geo] => [iso_language_code] => en [source] => <a href="http://twitter.com/">web</a> ) [4] => stdClass Object ( [profile_image_url] => http://a1.twimg.com/profile_images/431590520/BSL_icon_normal.gif [created_at] => Fri, 07 May 2010 16:35:12 +0000 [from_user] => BarclaysStock [metadata] => stdClass Object ( [result_type] => recent ) [to_user_id] => [text] => Investment ViewPoint - We take a look at what a hung parliament could mean for the UK economy http://bit.ly/OaYh7 [id] => 13557633799 [from_user_id] => 36238006 [geo] => [iso_language_code] => en [source] => <a href="http://twitter.com/">web</a> ) ) [max_id] => 13722716932 [since_id] => 0 [refresh_url] => ?since_id=13722716932&q=http%3A%2F%2Fbit.ly%2FOaYh7 [results_per_page] => 15 [page] => 1 [completed_in] => 0.026887 [query] => http%3A%2F%2Fbit.ly%2FOaYh7 )

    Read the article

  • php array count

    - by user295189
    I have a var dump of my sql query which return the following I wanna to count in the array below that how many rows of myID = 5 are there. How would I do that. I am using php. Thanks in advance array 0 = object(stdClass)[17] public 'myID' => string '5' (length=1) public 'data' => string '123' (length=3) 1 = object(stdClass)[18] public 'myID' => string '5' (length=1) public 'data' => string '123' (length=3) 2 = object(stdClass)[19] public 'relativeTypeID' => string '2' (length=1) public 'data' => string '256' (length=3) 3 = object(stdClass)[20] public 'myID' => string '4' (length=1) public 'data' => string '786' (length=3) object(stdClass)[21] public 'myID' => string '4' (length=1) public 'data' => string '786' (length=3)

    Read the article

  • Retrieving Data related to a top-level object from parse.com using PHP

    - by Albeert Tw
    I am retrieve related data using parse.com and PHP I get the top-leve object without problems but I can't access related data. ([myRelation] => stdClass Object ( [__type] => Relation [className] => other)) Please refer to my code below: $className = "myClass"; $url = 'https://api.parse.com/1/classes/' . $className; $appId = 'xxxxxx'; $restKey = 'xxxxxxx'; $relatedParams = urlencode('include=people'); $rest = curl_init(); curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($rest, CURLOPT_URL, $url .'/io1GzkzErH/'.$relatedParams); curl_setopt($rest, CURLOPT_HTTPGET, true); curl_setopt($rest, CURLOPT_RETURNTRANSFER, true); curl_setopt($rest, CURLOPT_HTTPHEADER, array("X-Parse-Application-Id: " . $appId, "X-Parse-REST-API-Key: " . $restKey, "Content-Type: application/json")); $response = curl_exec($rest); echo $response; I want to see related objects into myRelation. Current answer is: I get this answer: stdClass Object ( [Altres] => loremipsum. [Cartell] => stdClass Object ( [__type] => File [name] => f29efff4-5db1-451a-ab42-7569fbb955a7-cartell.jpg [url] => loremipsum.jpg ) [CartellURL] => [Categoria] => Comedia [Durada] => 120min [Estat] => Al teatre [Final] => stdClass Object ( [__type] => Date [iso] => 2014-06-18T22:00:00.000Z ) [Inici] => stdClass Object ( [__type] => Date [iso] => 2014-04-25T22:00:00.000Z ) [Nom] => Losers [Prioritat] => 0 [Sala] => loremipsum [Sinopsis] => loremipsum [TrailerURL] => loremipsum.com [URLEntrada] => loremipsum.com [URLProductora] => http://www.loremipsum.com [Visible] => 1 [createdAt] => 2014-05-20T12:01:06.094Z [objectId] => io1GzkzErH [people] => stdClass Object ( [__type] => Relation [className] => persones ) [updatedAt] => 2014-05-20T12:07:22.758Z ) loremipsum But I need to know what are in [people] = stdClass Object ( [__type] = Relation [className] = persones )

    Read the article

  • Displaying Array in Select - FORM API Drupal

    - by Krishma
    Hi: I want to add key(type_id) and value(type_description) to select in drupal form API $result_x-product_types-RPMProductType is array result from Database :- array(4) { [0]= object(stdClass)#18 (2) { ["type_description"]= string(10) "Calendered" ["type_id"]= int(1) } [1]= object(stdClass)#19 (2) { ["type_description"]= string(8) "Extruded" ["type_id"]= int(2) } [2]= object(stdClass)#20 (2) { ["type_description"]= string(6) "Molded" ["type_id"]= int(3) } [3]= object(stdClass)#21 (2) { ["type_description"]= string(5) "Other" ["type_id"]= int(4) } } foreach ($result_x-product_types-RPMProductType as $data) { $form['manufacturer_add_new_sales']['product_type'] = array( '#type' = 'select', '#title' = t('Product Type'), '#options'=array($data-type_id=$data-type_description), ); } When do so I am getting only last value i.e Other. How to correctly loop to bind Select to display all the array Key - Values. Thank you in advance.

    Read the article

  • Get Specific Data From Array, Based On Another Value

    - by A Smith
    I have an array that outputs these values: Array ( [0] => stdClass Object ( [ID] => 6585 [COLOR] => red [Name] => steve ) [1] => stdClass Object ( [ID] => 5476 [COLOR] => blue [Name] => sol ) [2] => stdClass Object ( [ID] => 7564 [COLOR] => yellow [Name] => jake ) [3] => stdClass Object ( [ID] => 3465 [COLOR] => green [Name] => helen ) ) Now, I will know the ID of the person, and I need the get the COLOR value for that specific value set. How is this best achieved please?

    Read the article

  • Convert enumerated records to php object

    - by Matt H
    I have a table containing a bunch of records like this: +-----------+--------+----------+ | extension | fwd_to | type | +-----------+--------+----------+ | 800 | 11111 | noanswer | | 800 | 12345 | uncond | | 800 | 22222 | unavail | | 800 | 54321 | busy | | 801 | 123 | uncond | +-----------+--------+----------+ etc The query looks like this: select fwd_to, type from forwards where extension='800'; Now I get back an array containing objects which look like the following when printed with Kohana::debug: (object) stdClass Object ( [fwd_to] => 11111 [type] => noanswer ) (object) stdClass Object ( [fwd_to] => 12345 [type] => uncond ) (object) stdClass Object ( [fwd_to] => 22222 [type] => unavail ) (object) stdClass Object ( [fwd_to] => 54321 [type] => busy ) What I'd like to do is convert this to an object of this form: (object) stdClass Object ( [busy] => 54321 [uncond] => 12345 [unavail] => 22222 [noanswer] => 11111 ) The reason being I want to then call json_encode on it. This will allow me to use jquery populate to populate a form. Is there a suggested way I can do this nicely? I'm fairly new to PHP and I'm sure this is easy but it's eluding me at the moment.

    Read the article

  • SQL: GROUP BY after JOIN without overriding rows?

    - by krismeld
    I have a table of basketball leagues, a table af teams and a table of players like this: LEAGUES ID | NAME | ------------------ 1 | NBA | 2 | ABA | TEAMS: ID | NAME | LEAGUE_ID ------------------------------ 20 | BULLS | 1 21 | KNICKS | 2 PLAYERS: ID | TEAM_ID | FIRST_NAME | LAST_NAME | --------------------------------------------- 1 | 21 | John | Starks | 2 | 21 | Patrick | Ewing | Given a League ID, I would like to retrieve all the players' names and their team ID from all the teams in that league, so I do this: SELECT t.id AS team_id, p.id AS player_id, p.first_name, p.last_name FROM teams AS t JOIN players AS p ON p.team_id = t.id WHERE t.league_id = 1 which returns: [0] => stdClass Object ( [team_id] => 21 [player_id] => 1 [first_name] => John [last_name] => Starks ) [1] => stdClass Object ( [team_id] => 21 [player_id] => 2 [first_name] => Patrick [last_name] => Ewing ) + around 500 more objects... Since I will use this result to populate a dropdown menu for each team containing each team's list of players, I would like to group my result by team ID, so the loop to create these dropdowns will only have to cycle through each team ID instead of all 500+ players each time. But when I use the GROUP BY like this: SELECT t.id AS team_id, p.id AS player_id, p.first_name, p.last_name FROM teams AS t JOIN players AS p ON p.team_id = t.id WHERE t.league_id = 1 GROUP BY t.id it only returns one player from each team like this, overriding all the other players on the same team because of the use of the same column names. [0] => stdClass Object ( [team_id] => 21 [player_id] => 2 [first_name] => Patrick [last_name] => Ewing ) [1] => stdClass Object ( [team_id] => 22 [player_id] => 31 [first_name] => Shawn [last_name] => Kemp ) etc... I would like to return something like this: [0] => stdClass Object ( [team_id] => 2 [player_id1] => 1 [first_name1] => John [last_name1] => Starks [player_id2] => 2 [first_name2] => Patrick [last_name2] => Ewing +10 more players from this team... ) +25 more teams... Is it possible somehow?

    Read the article

  • foreach: how to iterate this

    - by ilnur777
    object(stdClass)[1] public 'inbox' => array 0 => object(stdClass)[2] public 'from' => string '55512351' (length=8) public 'date' => string '29/03/2010' (length=10) public 'time' => string '21:24:10' (length=8) public 'utcOffsetSeconds' => int 3600 public 'recipients' => array 0 => object(stdClass)[3] public 'address' => string '55512351' (length=8) public 'name' => string '55512351' (length=8) public 'deliveryStatus' => string 'notRequested' (length=12) public 'body' => string 'This is message text.' (length=21) 1 => object(stdClass)[4] public 'from' => string '55512351' (length=8) public 'date' => string '29/03/2010' (length=10) public 'time' => string '21:24:12' (length=8) public 'utcOffsetSeconds' => int 3600 public 'recipients' => array 0 => object(stdClass)[5] public 'address' => string '55512351' (length=8) public 'name' => string '55512351' (length=8) public 'deliveryStatus' => string 'notRequested' (length=12) public 'body' => string 'This is message text.' (length=21) .... .... I have this foreach, but it does not iterate address, name, deliveryStatus! Could you show how to get this data? foreach ($data->inbox as $note) { echo '<p>'; echo 'From : ' . htmlspecialchars($note->from) . '<br />'; echo 'Date : ' . htmlspecialchars($note->date) . '<br />'; echo 'Time : ' . htmlspecialchars($note->time) . '<br />'; echo 'Body : ' . htmlspecialchars($note->body) . '<br />'; }

    Read the article

  • Displaying mysql results as an object?

    - by Michael
    If I have a database with the structure: ___id_____|____value____ 1 | value1 2 | value2 3 | value3 How can I pull data from this MySQL database in PHP and have it formatted like this: Array ( [0] => stdClass Object ( [id] => 1 [value] => value1 ) [1] => stdClass Object ( [id] => 2 [value] => value2 ) [2] => stdClass Object ( [id] => 3 [value] => value3 ) )

    Read the article

  • two php arrays - sort one array with the value order of another

    - by Tisch
    Hi there, I have two PHP arrays like so: Array of X records containing the ID of Wordpress posts (in a particular order) Array of Wordpress posts The two arrays look something like this: Array One (Sorted Custom Array of Wordpress Post IDs) Array ( [0] => 54 [1] => 10 [2] => 4 ) Array Two (Wordpress Post Array) Array ( [0] => stdClass Object ( [ID] => 4 [post_author] => 1 ) [1] => stdClass Object ( [ID] => 54 [post_author] => 1 ) [2] => stdClass Object ( [ID] => 10 [post_author] => 1 ) ) I would like to sort the array of wordpress posts with the order of the ID's in the first array. I hope this makes sense, and thanks in advance of any help. Tom edit: The server is running PHP Version 5.2.14

    Read the article

1 2 3 4  | Next Page >