Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-03-06 01:56:53

khellstr
Member
From: Helsinki, Finland
Registered: 2006-02-16
Posts: 12
Website

PHP: Converting string to array

In my customfield I have variable(input) like this: 2006,3,2,3,4,7,9,10,11,14,16,17,18,21,23,24,25,28,30

I wan’t to convert it to array inside txp:php tag

I think it should work whit code something like this:

$temp = custom_field( array("name"=>"custom_1") );

$arrayTemp = array(eval("$temp"));

but I just can’t get it working :(
.
update:
or something like this,
eval("\$arrayTemp = array(\" $temp\");"); but that doesn’t work either

update 2:
I want array to be like this
[0] => 2006
[1] =>3
[2] =>2 … … …

Last edited by khellstr (2006-03-06 02:14:37)

Offline

#2 2006-03-06 02:14:43

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: PHP: Converting string to array

$temp = explode(',', custom_field(array('name' => 'custom_1')));

Offline

#3 2006-03-06 02:39:23

khellstr
Member
From: Helsinki, Finland
Registered: 2006-02-16
Posts: 12
Website

Re: PHP: Converting string to array

Thank’s.

Offline

Board footer

Powered by FluxBB