Solved

Reading string to create links, easyone

Posted on 2006-07-23
2
186 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 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now