![]() |
PHP guys (or gals!) - quick question
I have data in a mysql table in the format:
description title:description text;description title2:description text2; etc Is there any way I put this into an array (or something simillar) to print it out and format it nicely? |
|
first explode the string on every ;, next explode every array element on :
http://de.php.net/manual/en/function.explode.php e.g.: $tmp = 'description title:description text;description title2:description text2'; $tmp2 = explode(';',$tmp); returns: $tmp2[0] = 'description title:description text'; $tmp2[1] = 'description title2:description text2'; now you could do something like: $tmp3 = array(); foreach($tmp2 AS $value){ $tmp3[] = explode(':',$value); } and you get $tmp3[0] = array( 0 => 'description title', 1 => 'description text' ); $tmp3[1] = array( 0 => 'description title2', 1 => 'description text2' ); |
You can use a query and put the result into an array. There is an example below. You will need html where the variables are integrated in the "while" loop.
PHP Code:
|
U smell of wee-wee
|
PHP Code:
Code:
Array |
in reference to my above post:
Code:
<? |
another thing if your PHP is set to super strict you may want to return $newarray as @$newarray to avoid tripping a warning if there is no data sent to the function.
|
Thanks fris, StariaDaniel, m4yadult & irbobo. That works!
|
just procrastinating
|
Quote:
|
All times are GMT -7. The time now is 11:09 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc