On Feb 19, 5:36 pm, rb <[email protected]> wrote:
> Although, I need to read up on array_combine.  The line of code
> that appends the School prefix is still a little foggy.  it's working,
> just not exactly sure *how* it's appending that prefix.

Example array:
Array(
           [zip_mail] => 90210
           [state_mail] => CA
)

Here's a breakdown of what's happening in the complex line after
Set::filter:

1. An array containing the keys of the form results array is retrieved
by using array_keys. This array returned by array_keys() contains: [0]
=> zip_mail, [1] => state_mail
2. A call to preg_replace is made on this array of keys which
essentially performs a regular expression replace operation for each
element in that array. The results of this "find and replace" are
returned by preg_replace. These results would contain: [0] =>
School.zip_mail, [1] => School.state_mail
3. An array containing the values of the form results array is
retrieved by using array_values. This array contains: [0] => 90210,
[1] => CA
4. A call to array_combine is made, which will combine the two
supplied arrays (the array returned by preg_replace, and the array
returned by array_values) to generate an associative array. It does
this by pairing the values of each array to form key=>value pairs
which are saved into a new array that is eventually returned. That
gives us a final resultant array of: [School.zip_mail] => 90210,
[School.state_mail] => CA

I hope that makes that line of code a little clearer. Additional
information on each of the PHP functions can be found in the PHP
manual at php.net. :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to