Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Implode?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Implode?

Postby danoshea » Thu Feb 21, 2013 2:02 pm

Can someone tell me how I can change this -

ABCDEFGHIJKLMNOPQRSTUVWXYZ

to this format all the way to Z -

A - B - C - D - E

From the following code??

I tried some of the implode code that is commented out...no go. Thx

<?php

$element = 'agents_broward_sample___last_name';

$url = 'http://'.$_SERVER['HTTP_HOST'].'/broward-agents-alphabetical-search';

$letters = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');

/* $letters = implode(" - ", $letters);
*/

foreach($letters as $l){


echo "<a href='{$url}?resetfilters=1&".$element."[value]=$l%25&".$element."[condition]=LIKE'>$l</a>";

/* echo "<a href='{$url}?resetfilters=1&".$element."[value]=$l%25&".$element."[condition]=LIKE'>$l</a>";
*/

}

?>
danoshea
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Feb 21, 2013 1:55 pm

Re: Implode?

Postby seandisanti » Mon Feb 25, 2013 9:59 am

str_split() first to create your array, then implode it to a string.
Code: Select all
<?php
$letters= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$letters = str_split($letters,1);
$letters = implode (' - ',$letters);
echo $letters;
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron