Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reading string to create links, easyone

Posted on 2006-07-23
2
Medium Priority
?
199 Views
Last Modified: 2008-07-03
I have the following string:

a:22:{i:0;s:25:"sometext";i:1;s:13:"sometext";i:2;s:24:"sometext";i:3;s:25:"sometext";i:4;s:14:"sometext";i:5;s:11:"sometext";i:6;s:8:"sometext";i:7;s:11:"sometext";i:8;s:19:"sometext";i:9;s:24:"sometext";i:10;s:18:"sometext";i:11;s:14:"sometext";i:12;s:15:"sometext";i:13;s:15:"sometext";i:14;s:10:"sometext";i:15;s:19:"sometext";i:16;s:16:"sometext";i:17;s:17:"sometext";i:18;s:31:"sometext";i:19;s:52:"sometext";i:20;s:39:"sometext";i:21;s:25:"sometext";}

the format is: i:id;s:# of characters:"text";

I would like to create a list of links which contains links for items in the above string, each link should take the "id" and "text" parts and format them as follows:
<a href="file.php?param=id">sometext</a>

I think we should use split function using ragular expersion and put them in an array or something, but I don't know how to do it.  Any help!
0
Comment
Question by:mafairuz
2 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 17162499
Hi,

You probably can use:

$array = unserialize($string);

then use
foreach($array as $key => $value) {
  echo '<a href="file.php?param='.intval($key).'">'.htmlspecialchars($value).'</a>';
}

-r-
0
 
LVL 3

Author Comment

by:mafairuz
ID: 17162525
just amazing :o

it worked perfectly .. :)

Thanks Roonaan
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question