$entries = ldap_get_entries($ldapconn, $ldapsearch); // This is my result form ldap server
$format = "@sn, @givenname, E: @mail"; // This are new strings to replace ldap defualt attribures.
if ( $entries ) { // Check $entries are not empty.
# Try to authenticate to each until we get a match
for ( $i = 0 ; $i < $entries['count']; $i++ ) {
$result = $format;
foreach ($entries[$i] as $key => $entrie) {
echo $result."
";
$result = str_replace($result, '@'.$key, $entrie[0]);// This is the problem I'm having I try to replace the strings from $result but doesn't looks like it's working.
//$cat = $entries[$i][$key][0];
$contact_data[] = $result;
}
var_dump($result);
die();
}
}
print json_encode($contact_data);
问题替换LDAP默认属性
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- douchangmian0305 2010-07-20 08:37关注
Look at the documentation of str_replace:
http://www.php3.de/str_replace
str_replace ( $search , $replace , $subject )
Example:
$search = "@sn"; $replace = "Foobar"; $subject = "ABC @sn DEF"; echo str_replace ( $search , $replace , $subject )
This would print "ABC Foobar DEF"
So it looks like you have to fix the order of the parameters to the str_replace function.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 YoloV5 第三方库的版本对照问题
- ¥15 请完成下列相关问题!
- ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
- ¥15 求daily translation(DT)偏差订正方法的代码
- ¥15 js调用html页面需要隐藏某个按钮
- ¥15 ads仿真结果在圆图上是怎么读数的
- ¥20 Cotex M3的调试和程序执行方式是什么样的?
- ¥20 java项目连接sqlserver时报ssl相关错误
- ¥15 一道python难题3
- ¥15 牛顿斯科特系数表表示