rfc:to-array

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
rfc:to-array [2020/02/04 13:02] – Update status to under discussion stevenwadejrrfc:to-array [2020/02/11 12:52] – Remove reference to print_r() casting to array stevenwadejr
Line 44: Line 44:
  
 <code php> <code php>
-print_r($person); // calls __toArray() 
- 
-// Output 
-/* 
-Array 
-( 
-    [name] => John Doe 
-    [email] => j.doe@example.com 
-) 
-*/ 
- 
 $personArray = (array) $person; // casting triggers __toArray() $personArray = (array) $person; // casting triggers __toArray()
 </code> </code>
Line 106: Line 95:
  
 <code php> <code php>
-print_r(array_keys($person));+print_r( 
 +    array_keys($person) 
 +);
  
 // Output // Output
rfc/to-array.txt · Last modified: 2020/02/11 13:57 by stevenwadejr