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
Solved

Reading string to create links, easyone

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

839 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