Parsing Drupal String
I am writing my own drupal website si开发者_Go百科de API.
I see that some tables containg some odd strings that i need to pharse, I cant fine any logic in it. for example, I have upload via the admin a file and i have found the relevant row with the data.a:12:{s:3:"alt";s:10:"aaaaaaaaaa";s:3:"fid";s:2:"22";s:5:"width";i:1024;s:6:"height";i:680;s:8:"duration";i:0;s:12:"audio_format";s:0:"";s:17:"audio_sample_rate";i:0;s:18:"audio_channel_mode";s:0:"";s:13:"audio_bitrate";i:0;s:18:"audio_bitrate_mode";s:0:"";s:4:"tags";a:0:{}s:5:"title";s:0:"";}
I need to pharse out the aaaaaaaaaa string which is the image "alt".
Do you have an idea of how to parse this string, I hope that your rule will be soutable for drupa odd strings in general? ThanksThese strings are not Drupal-specific. They are serialized PHP data types (objects, arrays, etc.). See the PHP manual for serialize().
The string you've quoted is a PHP serialized array. See the PHP manual page for the serialize() and unserialize() functions for more info.
However I strongly doubt that you actually need to be delving into the data in this way. That data will have been set up in Drupal, and can be modified in Drupal. I can't say where, since the data you've provided is lacking context, but it'll likely be somewhere in your administration area.
I'd suggest you find where it's configured and change it there. Hacking around directly with the serialized strings that Drupal creates is a sure-fire way to damage your Drupal installation if you don't know what you're doing.
That string is serialised. You can unserialize it using http://php.net/manual/en/function.unserialize.php
精彩评论