开发者

checking value if it serialized or not

I have data stored in database tables as serialized.

One of my functions needs to return true if the value is serialized.

foreac开发者_JAVA技巧h($data as $r):
if($r->options is serialized) {
  $unserialized_value = unserialize($r->options);
}
endforeach;


i think you should specify the column that you know that's serialized and apply this code

 function c($r=$result_array){

    $full_unserialize_array=array();
    foreach($r as $s){

     $p= @unserialize($s);
     if($p == false){
       $full_unserialize_array[]=$s;

     }else{
       $full_unserialize_array[]=$p;
     }//end else
}//end foreach
 return $full_unserialize_array;

 }//end function c
  print_r($full_unserialize_array);

i'm sorry i'm new here ^_^

`


there's a couple of functions out there:

is_serialized http://www.cs278.org/blog/2009/10/23/php-function-is_serialized/

couple more suggestions here: Check to see if a string is serialized?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜