Solved

Reading string to create links, easyone

Posted on 2006-07-23
2
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 125 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

752 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