Jump to content

need help with this function


Looktrne

Recommended Posts

I have a function that is a bit corrupted

 

could anyone tell me how to make this a working function?

 

thanks in advance

 

Paul

 

function array_addslashes( $arr )
{
    foreach ( $arr as $key => $UNKNOWN )
    {
        if ( is_array( $UNKNOWN ) )
        {
          $arr  [$key] = array_addslashes( $UNKNOWN);
        }
        else
        {
          $arr [$key] = addslashes( $UNKNOWN );
        }
    }
    return $arr;
}

 

$UNKNOWN

 

needs to be a variable but I am not sure on what it should be

 

thanks for any tips on this

 

Paul

Link to comment
https://forums.phpfreaks.com/topic/160565-need-help-with-this-function/
Share on other sites

I'm not exactly sure what you want to do. You didn't state the purpose of the function.

 

I assume you mean this -

<?php

function array_addslashes ($arr) {
     foreach ($arr as $key => $val) {
          if (is_array($val)) $arr[$key] = array_addslashes($val);
          else $new_arr[$key] = addslashes($val);
     }
     return $arr;
}

Thats why I linked it to the manual lol

 

You could also try imploding the array into a string and using addslashes on the string before exploding it back into an array, the index's will be reset tho 

 


function array_addSlashes( $arr )
{
$arr = implode(",", $arr);
$arr = addSlashes($arr);

   return explode(",", $arr);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.