Keyword

name:N,value:1,target:null extract string data to

  • Aristos Aristodemou
  • Aristos Aristodemou's Avatar Topic Author
  • Offline
  • New Member
More
12 years 6 months ago #63667 by Aristos Aristodemou
name:N,value:1,target:null extract string data to was created by Aristos Aristodemou
I use the following comman:

$db = &JFactory::getDBO() ;
$query = "SELECT value FROM #__k2_extra_fields ";
$query.= "WHERE name = 'City'";

$db->setQuery($query);
$rows2=$db->loadResult();

and i get this:
name":"Nicosia","value":1,"target":null},{"name":"Larnaka","value":2,"target":null},{"name":"Limassol","value":3,"target":null},{"name":"Ammochostos","value":4,"target":null},{"name":"Pafos","value":5,"target":null}]name":"Nicosia","value":1,"target":null},{"name":"Larnaka","value":2,"target":null},{"name":"Limassol","value":3,"target":null},{"name":"Ammochostos","value":4,"target":null},{"name":"Pafos","value":5,"target":null}]

i want to extract these data to these form:
Nicosia, Larnaka, Limassol, Ammochostos, Pafos

basically is there any loop to take them sequentially (for each loop) how i extract them correctly?

Please Log in or Create an account to join the conversation.

  • Aristos Aristodemou
  • Aristos Aristodemou's Avatar Topic Author
  • Offline
  • New Member
More
12 years 6 months ago #63668 by Aristos Aristodemou
Replied by Aristos Aristodemou on topic Re: name:N,value:1,target:null extract string data to
is there a ready made function of K2 or php function or i have to use classic php functions like split, explode, implode etc???

Please Log in or Create an account to join the conversation.

  • Aristos Aristodemou
  • Aristos Aristodemou's Avatar Topic Author
  • Offline
  • New Member
More
12 years 6 months ago #63669 by Aristos Aristodemou
Replied by Aristos Aristodemou on topic Solved
$rows2=$db->loadResult();
$rows2 = explode("\"", $rows2);

for ($index=3; $index<count($rows2); $index+=8){
echo $rows2[$index] . "<br>";
}


The following works!!!

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum