473,382 Members | 1,204 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How do make extract values from serialized data?

26
In my student table one field data is like below. I need to display as a paragraph. for ex: career:......... and story:.....)

Expand|Select|Wrap|Line Numbers
  1. "a:3:{s:5:""carer"";s:0:"""";s:5:""story"";s:0:"""";s:5:""other"";s:0:"""";}" "a:3:{s:5:""carer"";s:591:""Ang Mei Kee was a student of (APS) from Jan 2009 to Nov 2010 During her time at APS, Mei Kee has demonstrated care for her fellow classmates. She always takes the initiative to assist her teachers and to remind her classmates to wear proper baking attire before entering the workshop. She has always been neat and takes pride in being a role model. For others She has the ability to encourage her peers to take care of their well being and to motivate them to greater heights. Mei Kee also participated achievely in the overseas service learning at Batam Indonesia."";s:5:""story"";s:432:""During her overseas service learning (Montfort Challenge program), Mei Kee was appointed as a team leader. She was able to come out with her group goals and target; and spurred her teammates to make a commitment to one another to act and achieve these goals together with her peers and put in a lot of effort to teach some simple English for the orphans in Batam. She was positive and was able to carry out tasks assigned to her . "";s:5:""other"";s:288:""Ang Mei Kee has always shown herself to be a very artistic person. She likes fashion design and aspires to be a fashion designer in the future. Currently she is helping her sister in a fashion boutique to strengthen her designing skills,she does help during school holidays and weekends."";}"
  2.  
I need the display the data in paragraph format as below. How would I do it?

for ex:
Expand|Select|Wrap|Line Numbers
  1. carer
  2. Ang Mei Kee was a student of (APS) from Jan 2009 to Nov 2010 During her time at APS, Mei Kee has demonstrated care for her fellow classmates. She always takes the initiative to assist her teachers and to remind her classmates to wear proper baking attire before entering the workshop. She has always been neat and takes pride in being a role model. For others She has the ability to encourage her peers to take care of their well being and to motivate them to greater heights. Mei Kee also participated achievely in the overseas service learning at Batam Indonesia.
  3.  
  4. Story
  5.  
  6. uring her overseas service learning (Montfort Challenge program), Mei Kee was appointed as a team leader. She was able to come out with her group goals and target; and spurred her teammates to make a commitment to one another to act and achieve these goals together with her peers and put in a lot of effort to teach some simple English for the orphans in Batam. She was positive and was able to carry out tasks assigned to her .
  7.  
  8. Other
  9. Ang Mei Kee has always shown herself to be a very artistic person. She likes fashion design and aspires to be a fashion designer in the future. Currently she is helping her sister in a fashion boutique to strengthen her designing skills,she does help during school holidays and weekends.
  10.  
Mar 1 '11 #1

✓ answered by dgreenhouse

The data you provided "looks" like serialized data but is invalid. Where did the data come from?

See the serialize() and unserialize() PHP functions.

With valid serialized data that has been unserialized, you can access each value as an array element. After that, it's simple a matter of placing the array element that would go in a paragraph in an HTML paragraph element (i.e. <p> </p>).

By the way, the data is invalid because of the double-double quotes.

Expand|Select|Wrap|Line Numbers
  1. This:
  2. "a:3:{s:5:""carer"";s:0:"""";s:5:""story"";s:0:"""";s:5:""other"";s:0:"""";}"
  3.  
  4. Should be this:
  5. 'a:3:{s:5:"carer";s:0:"";s:5:"story";s:0:"";s:5:"other";s:0:"";}'
  6.  
If the data source is generating the double-double quotes, you could use the str_replace() function to eliminate the double-double quotes.

Expand|Select|Wrap|Line Numbers
  1. $str = str_replace('""','"','a:3:{s:5:""carer"";s:0:"""";s:5:""story"";s:0:"""";s:5:""other"";s:0:"""";}"');
  2. $ustr = unserialize($str);
  3.  
  4. print_r($ustr);
  5.  

2 4129
dgreenhouse
250 Expert 100+
The data you provided "looks" like serialized data but is invalid. Where did the data come from?

See the serialize() and unserialize() PHP functions.

With valid serialized data that has been unserialized, you can access each value as an array element. After that, it's simple a matter of placing the array element that would go in a paragraph in an HTML paragraph element (i.e. <p> </p>).

By the way, the data is invalid because of the double-double quotes.

Expand|Select|Wrap|Line Numbers
  1. This:
  2. "a:3:{s:5:""carer"";s:0:"""";s:5:""story"";s:0:"""";s:5:""other"";s:0:"""";}"
  3.  
  4. Should be this:
  5. 'a:3:{s:5:"carer";s:0:"";s:5:"story";s:0:"";s:5:"other";s:0:"";}'
  6.  
If the data source is generating the double-double quotes, you could use the str_replace() function to eliminate the double-double quotes.

Expand|Select|Wrap|Line Numbers
  1. $str = str_replace('""','"','a:3:{s:5:""carer"";s:0:"""";s:5:""story"";s:0:"""";s:5:""other"";s:0:"""";}"');
  2. $ustr = unserialize($str);
  3.  
  4. print_r($ustr);
  5.  
Mar 1 '11 #2
apssiva
26
Hi,

Thank you so much for your help, it's working. I am new for PHP, so its take time to understand. i got the answer. I am so happy :)
Mar 1 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Geoffrey | last post by:
I am working on a file conversion project that reads data from a one file format, reformats in and writes in out to another. The data is records of informations - names address, account...
0
by: Magic1812 | last post by:
Magic Software invites you to join us this coming Tuesday (January 27th, 2004) at 12:00 EDT / 17:00 GMT for a FREE live Webinar: Title: Data Integrity Using eDeveloper Date: January 27, 2004...
1
by: Bart | last post by:
Dear all, I would like to encrypt a large amount of data by using public/private keys, but I read on MSDN: "Symmetric encryption is performed on streams and is therefore useful to encrypt large...
0
by: oracle | last post by:
Greetings, I have a combo box that I binded to a data set using text and tags. I want it to display the DRT.Name property and have a DRT.UnitId as a value. ...
2
by: Gary42103 | last post by:
Hi I need Perl Script to do Data Parsing using existing data files. I have my existing data files in the following directory: Directory Name: workfs/ams Data File Names: 20070504.dat,...
5
by: orabalu | last post by:
Hi Guys, Can you give me some examples for Incremental load in PL/SQL for Datawarehouse projects. Regards, Balu
0
by: sijugeo | last post by:
Hi, I Have a MS word template field which have certain data fields. I want to populate the data fields using the data retrived from SQL db. How can I do this? Thanks in advance Siju george
1
by: azura | last post by:
i had a problem... how can i auto detect that bold n italic field..when i enter the matric no, then the name will auto appear... i want to make this field using less button.. thanks <table...
5
by: DR | last post by:
Why is its substantialy slower to load 50GB of gzipped file (20GB gzipped file) then loading 50GB unzipped data? im using System.IO.Compression.GZipStream and its not maxing out the cpu while...
3
by: ndoe | last post by:
how to make a paragraph from file to file like this e.g data.txt i want eat some pizza with
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.