Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reading string to create links, easyone

Posted on 2006-07-23
2
Medium Priority
?
196 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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.
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 look for a specific file type in a local or remote server directory using PHP.

722 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