* Thus wrote Katie Marquez ([EMAIL PROTECTED]):
> I want to have an array, perform an action on the
> values in the array, and have those actions
> permanently affect the values in the array. Here's
> something I've written to test it out how I thought it
> could be done:
>
> <?php
> $array = ('zero\0', 'one\1', 'two\2', 'three\3');
> // look at array before changes
> print_r($array);
> // maybe use foreach or array_walk next?
> foreach ($array as $value)
> {
> stripslashes($value);
First: Most php functions always return a modified version of the
variable instead of modifying them directly. So in order to
actually keep the changes:
$value = stripslashes($value);
Second:
If you are using php 5 you can do something like, note the way
$value is referenced with &:
foreach($array as &$value) {
$value = stripslashes($value);
}
php 4's foreach always works on a copy so you have to access the
array directly:
foreach($array as $index => $value) {
$array[$index] = $value;
}
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php