如何在第292点将此字符串反序列化为显示错误?

时间:2012-01-27 08:46:41

标签: php serialization

这是我的序列化形式的字符串。当我尝试反序列化(转换为数组)字符串我被给出错误时,请看下面的序列化字符串

a:6:{s:5:"width";s:3:"614";s:6:"height";s:3:"414";s:14:"hwstring_small";s:23:"height='86' width='128'";s:4:"file";s:171:"2011/02/Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok.jpg";s:5:"sizes";a:9:{s:9:"thumbnail";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-162x160.jpg";s:5:"width";s:3:"162";s:6:"height";s:3:"160";}s:6:"medium";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-258x173.jpg";s:5:"width";s:3:"258";s:6:"height";s:3:"173";}s:5:"large";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-530x357.jpg";s:5:"width";s:3:"530";s:6:"height";s:3:"357";}s:12:"post-special";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-530x380.jpg";s:5:"width";s:3:"530";s:6:"height";s:3:"380";}s:8:"post-top";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-110x110.jpg";s:5:"width";s:3:"110";s:6:"height";s:3:"110";}s:9:"post-tiny";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-108x100.jpg";s:5:"width";s:3:"108";s:6:"height";s:3:"100";}s:9:"post-item";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-455x327.jpg";s:5:"width";s:3:"455";s:6:"height";s:3:"327";}s:11:"post-review";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-162x166.jpg";s:5:"width";s:3:"162";s:6:"height";s:3:"166";}s:9:"post-poll";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-285x237.jpg";s:5:"width";s:3:"285";s:6:"height";s:3:"237";}}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}}

我收到错误

Notice: unserialize() [function.unserialize]: Error at offset 292 of 2873 bytes

请帮助并告诉我序列化字符串的最佳方法是什么 下面是我原来的数组

array (
  'width' => '614',
  'height' => '414',
  'hwstring_small' => 'height='86' width='128'',
  'file' => '2011/02/Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok.jpg',
  'sizes' => 
  array (
    'thumbnail' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-162x160.jpg',
      'width' => '162',
      'height' => '160',
    ),
    'medium' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-258x173.jpg',
      'width' => '258',
      'height' => '173',
    ),
    'large' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-530x357.jpg',
      'width' => '530',
      'height' => '357',
    ),
    'post-special' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-530x380.jpg',
      'width' => '530',
      'height' => '380',
    ),
    'post-top' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-110x110.jpg',
      'width' => '110',
      'height' => '110',
    ),
    'post-tiny' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-108x100.jpg',
      'width' => '108',
      'height' => '100',
    ),
    'post-item' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-455x327.jpg',
      'width' => '455',
      'height' => '327',
    ),
    'post-review' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-162x166.jpg',
      'width' => '162',
      'height' => '166',
    ),
    'post-poll' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-285x237.jpg',
      'width' => '285',
      'height' => '237',
    ),
  ),
  'image_meta' => 
  array (
    'aperture' => '0',
    'credit' => '',
    'camera' => '',
    'caption' => '',
    'created_timestamp' => '0',
    'copyright' => '',
    'focal_length' => '0',
    'iso' => '0',
    'shutter_speed' => '0',
    'title' => '',
  ),
)

感谢

//新数据 我做了171到169 当我json_encode('任何图像'); 它给予null

1 个答案:

答案 0 :(得分:1)

您是否使用序列化字符串进行任何操作?任何字符集编码(从UTF跳转到ASCII,反之亦然),html实体编码/解码或其他什么? 这个

  171::

的“2011/02 / Classis-Pallela从 - Embrujo-弗拉门戈-AT-97-丹福思-大道 - 我们挑选最经典的版本-59换两制成-with最独特和超吸收性邦巴-rice.-ok.jpg“

引号之间的长度应为171个字符,但长度仅为169个字符。当然,它会在反序列化过程中产生错误。

ps:检查包含该数据的原始字符串的长度。