Custom ['_Link']

13 posts by 4 authors in: Forums > CMS Builder
Last Post: April 27, 2010   (RSS)

Re: [aev] Custom ['_Link']

By Dave - April 27, 2010

Ahh, yes. Good question. Once your done with your reference variable you want to "unset" the reference so future use of that variable ($record) won't modify the data it was "pointing" at. See: http://www.php.net/manual/en/language.references.unset.php

Unset only clears the "pointer" as shown:

$a = "hello";
$b = &$a; // b is now a reference (pointer) to $a
$b = "world";
unset($b); // unsets $b only
print $a; // prints "world";
print $b; // produces error: Undefined variable: b
exit;


You can use this generic code for adding or changing values in a record list:
// create custom _link values
foreach (array_keys($newsRecords) as $index) {
$record = &$newsRecords[$index];

// ... modify record here ...

unset($record);
}


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

By aev - April 27, 2010

Thank you very much for explaining all this, learned a lot from it :)

-aev-