Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
Re: PHP: Converting string to array
Thank’s.
Offline
Pages: 1