Jump to content

[ARRAYS] Passing array as URL parameter


flaab

Recommended Posts

Hello 2all =)

 

I'll go straigh to the point. I'm programming a little search engine for my site.

The search function returns an array with the ID's of the databases retrievals for the users criteria.

 

Example: $retrievals = array(2,56,57,190,257,346,...,whatever);

 

And i want to split the results to view only 20 per page.

 

So, i need to pass that array as a parameter for an url.

 

Example: <a href="whatever.php?retrievals=<?php print $retrievals; ?>

 

And let the array be received by another document.

 

How can i do that?

 

Is there a better way to do this?

 

Thanks a lot.

Link to comment
https://forums.phpfreaks.com/topic/40046-arrays-passing-array-as-url-parameter/
Share on other sites

A better approach what I think would br serialize it and then unserialize it on next paga

 

$strRetrievals = serialize($retrievals);

 

<a href="whatever.php?retrievals=<?php print $strRetrievals; ?>

 

and on next page you can use

 

$strRetrievals = $_GET['retrievals'];

$arrRetrievals = unserialize($strRetrievals);

 

hope you find it useful for future use.....  ;)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.